#rust
60 articles about rust
Filter by topic
AI Commit Messages Without Handing Over Your Git History
AI git tooling tends to come in two shapes: a text box you copy out of, or an agent that runs commands and tells you afterwards. There is a third option, and it comes down to where the approval sits.
AIS Runner: A Desktop GUI for Local Azure Logic Apps Standard Development
AIS Runner is a Dioxus-based desktop app for local Azure Logic Apps Standard development — manage, run, debug, and compare workflows without leaving your dev environment.
What is `clamp` in Rust, and when should you use it?
What clamp does, why it panics on a swapped min and max, and how it differs from the saturating arithmetic it gets confused with.
What is &mut *x (reborrow) in Rust, and why does it freeze the original reference?
A reborrow duplicates the reference, not the data, and freezes the original for its duration. What &mut *x really does.
Instruction-Level Optimization: #[inline(always)]
Strategic application of Rust's #[inline(always)] attribute for instruction-level optimization, covering effective usage patterns and risks of overuse
Align data structures to cache lines
Designing cache-aligned data structures in multi-threaded Rust applications to prevent false sharing and optimize performance for large dataset processing
Mastering Inline Assembly in Rust: When and How to Optimize Safely
Low-level optimization in Rust, focusing on using inline assembly for performance-critical tasks
Understanding Rust Move Closures: A Guide for JavaScript Developers
Learn how Rust move closures work compared to JavaScript closures - ownership, threading, and when to use the move keyword
Profiling Rust: Tackling L1 Cache Misses with perf, Flamegraph, and Criterion
Low-level optimization in Rust, focusing on profiling tools to identify and fix performance bottlenecks like L1 cache misses
Boosting Rust Hot Loops: Slashing Branch Mispredictions
Low-level optimization in Rust, focusing on minimizing branch mispredictions in performance-critical loops
SIMD in Rust: Optimizing Matrix Multiplication
Leveraging Rust’s SIMD support for accelerating matrix multiplication with considerations for portability and correctness
Zero-Cost Abstractions: How Rust Optimizes Iterator Chains
Low-level optimization in Rust, focusing on iterator chains and zero-cost abstractions
Vec::push() in a loop vs. pre-allocating with Vec::with_capacity()?
Comparing performance of Vec::push() in loops versus pre-allocating with Vec::with_capacity(), analyzing memory reallocation costs and optimization strategies
Avoiding heap allocation on a real-time path
Leveraging Rust's stack-based features like fixed-size arrays and Option to eliminate heap allocations in real-time systems for predictable, low-latency execution
Blanket implementations: one impl for every type that qualifies
Employing blanket implementations in Rust to minimize code duplication for maintainable libraries
Associated types vs. generics in a low-level I/O driver API
Utilizing associated types in Rust traits to design flexible, type-safe APIs for low-level I/O drivers and comparing advantages over generic type parameters
Deadlocks in C vs Rust: What Does Rust Really Prevent?
Deadlocks aren't prevented by compilers—but Rust adds safety guarantees that make writing deadlock-prone code harder. Here's how it compares to C.
?Sized: writing one function for both sized and unsized types
Understanding the role of ?Sized bounds in Rust trait definitions and leveraging them to create flexible functions that work with both sized and unsized types efficiently
Supertraits: enforcing a hierarchy of behaviours
Leveraging supertraits to establish behavior hierarchies and combining them with where clauses to optimize complex generic algorithms for performance and type safety
Making Traits Object-Safe for Rust's dyn Trait in Plugin Systems
Understanding object safety in Rust and refactoring traits for dynamic dispatch
Trait bounds or dyn Trait? Static and dynamic dispatch compared
Generics with a trait bound compile to static dispatch; dyn Trait compiles to a vtable lookup. What each costs, and how to choose.
Trait Bounds
Using trait bounds in Rust for type safety and performance in mathematical computations
Mutable vs. immutable borrows: the two rules
The two borrowing rules, why exclusivity is the one that matters, and what the borrow checker actually rejects.
Rust Operators & Iterators: Quick Reference
Essential Rust operators, iterator differences, and Unicode handling you need to know.
Where do string literals (&str) live?
String literals live in the binary's read-only data with a 'static lifetime — what that means for allocation, copying, and returning them.
What is the purpose of Box<T> in Rust?
What Box<T> is for, what the extra indirection costs, and when a heap allocation is the right call rather than a reflex.
Why &str Won't Fit &String in Rust: Fun Fixes for String Mismatches!
Why passing a &str where a &String is expected fails to compile, what deref coercion does and doesn't do, and how to fix the mismatch.
How does Rust prevent dangling pointer at compile time?
Why a dangling pointer is a compile error in Rust rather than a crash in production, and how lifetimes make that check possible.
How does ownership prevent memory leaks and data races?
How the ownership rules close off memory leaks and data races before the program ever runs, and where they stop short.
Stack vs. Heap in Rust: Where Does Your Data Live?
What actually decides whether a value lands on the stack or the heap in Rust, and what each choice costs you at runtime.
How does Rust ensure memory safety without a garbage collector?
Ownership, borrowing and lifetimes give Rust memory safety at compile time, with no collector and no runtime pauses to budget for.
How does Cow<'a, B> (Copy-on-Write) work in Rust?
Cow<'a, B> lets a function borrow when it can and allocate only when it must. How copy-on-write works and when it pays for itself.
Understanding the Drop Trait in Rust
How the Drop trait works, when the destructor runs, and why implementing it by hand is rarer than it looks.
How Rust's Ownership and Borrowing Ensure Safe Concurrency
Ownership and borrowing rule out data races at compile time. What Send and Sync add, and why Rc can't cross a thread boundary.
Flatten a Vec<Vec<T>> into a Vec<T> using iterators
Flattening Vec<Vec<T>> using iterators compared to manual concatenation, analyzing performance implications
Vec::retain() Vs filtering with iter().filter().collect()?
Comparing Vec::retain() in-place filtering with iter().filter().collect() for different filtering scenarios and performance implications
Vec::drain() Vs Vec::truncate() or Vec::clear()?
Understanding Vec::drain() functionality and comparing it with Vec::truncate() and Vec::clear() for different element removal scenarios
What is the difference between Box<[T]> and Vec<T>?
Comparing Box<[T]> and Vec<T> differences in mutability, memory overhead, and performance implications for different use cases
How do you remove duplicates from a Vec<T> where T: Eq + Hash?
Efficient approaches to remove duplicates from Vec<T> where T: Eq + Hash, comparing HashSet-based and sort-based methods with performance analysis
Rust's collect() Magic: Turning Iterators into Vecs, HashMaps, and Strings!
How collect() decides what to build, what FromIterator asks of the target type, and how to steer it towards a Vec, a HashMap or a String.
How do you store a closure in a struct?
Storing closures in structs using generic parameters, trait objects, and lifetime annotations with Fn, FnMut, and FnOnce bounds
Implications of iterating over a Vec with .into_iter() instead of .iter()
Understanding the differences between .into_iter() and .iter() when iterating over Vec, covering ownership implications and performance considerations
Rust's Higher-Order Functions: Powering Flexible Closures
Exploring higher-order functions in Rust for functional programming patterns
How do you handle lifetimes when returning a closure that captures variables from its environment?
Managing lifetimes when returning closures that capture variables, covering ownership transfer, lifetime annotations, and avoiding dangling references in Rust
Using closures versus regular functions ?
Analyzing performance overhead of closures versus regular functions in Rust, covering static dispatch, heap allocation, and optimization scenarios
Rust's Stateful Closures: Passing and Mutating Across Multiple Calls
Managing stateful closures in Rust for repeated function calls
impl Fn() vs. Box<dyn Fn()>: Rust's Closure Dispatch Showdown
Comparing static and dynamic dispatch for closures in Rust, focusing on performance and use cases
What are move closures (move || { ... })? When are they necessary, and how do they interact with ownership?
What move actually moves, when you genuinely need it (threads, returned closures, async blocks), and how it interacts with ownership.
How do into_iter(), iter(), and iter_mut() differ?
into_iter(), iter() and iter_mut() differ in what they hand you: the value, a shared reference, or an exclusive one.
What are the differences between Fn, FnMut, and FnOnce?
Fn, FnMut and FnOnce aren't traits you pick — the compiler derives them from how the closure uses what it captured.
How do you specify a closure as a function parameter or return type?
Taking and returning closures: when impl Fn is enough, when you need Box<dyn Fn>, and what each choice costs at the call site.
Rust Traits vs. Java/C# Interfaces: Shared Behavior Done Right
Discussion on Rust traits vs Java/C# interfaces, covering dispatch mechanisms, compile-time behavior, and performance optimizations.
String vs. &str – Which to Use and When?
String vs str in Rust, covering memory management, ownership, and when to use each type.
Functions or Closures in Rust? Know the Difference!
Functions vs closures in Rust, covering ownership, traits, lifetimes, and performance implications.
Rust's repr: Optimize Struct Memory for Cache Efficiency
Low-level memory optimization in Rust, covering repr attributes, cache efficiency, and performance trade-offs
Rust Vec::new() vs. with_capacity(): When to Use Each
Vec allocation strategies in Rust, comparing Vec::new() and Vec::with_capacity() for optimal performance.
Getting Started with Rust: A Guide for Beginners
Introduction to Rust for beginners, covering installation, basic syntax, and your first project.
Rust: Memory Safety Without Garbage Collection
Rust gives you the performance of C with memory safety enforced at compile time. Learn how ownership and borrowing eliminate entire bug classes.
C Gives You Control, But at What Cost?
C avoids garbage collection and gives manual memory control, but opens the door to dangerous bugs. Explore real-world memory issues and why they matter.
GC Pauses and Latency: The Hidden Cost of High-Level Languages
Java, Python, and JavaScript offer convenience, but garbage collection introduces unpredictable latency. Explore how runtime memory management affects performance in real systems.