u/Dear_Spring7657in r/rust • Recommends
On “why is str a type if only &str is used?”
Intermediate. Assumes working knowledge.
239K views3 years ago7 recommendations
Programming languagesSystems programmingRustMemory managementPerformance and optimization
Logan Smith explains why and how to use Arc and Rc for immutable, reference-counted strings and dynamic arrays in Rust to avoid deep cloning.
Rust lets you do efficient reference-counted strings and dynamic arrays using Arc basically just as easily as their owning (and deep-cloning) equivalents, String and Vec respectively. So why not use them as a reasonable default, until you actually need the mutability that String and Vec provide? Get into the weeds with me here, feat. some cool visualizations, with special guest appearance from Box. This video assumes some familiarity with Rust and its core smart pointer types, namely Vec/String/Rc/Arc/Box, along with data structures like HashMap and BTreeMap, and traits like Clone, Hash, Ord, and serde::{Serialize, Deserialize}. serde feature flag for Rc/Arc: serde.rs/feature-flags.html#-features-rc Arc docs: doc.rust-lang.org/std/sync/struct.Arc.html Vec docs: doc.rust-lang.org/std/vec/struct.Vec.html Smart pointers in Rust: youtube.com/watch?v=8O0Nt9qY_vo animations: manim.community/What people say. Recommended for its clear explanation of using Arc and Rc for read-only cloning and string interning in Rust.
u/Dear_Spring7657in r/rust • Recommends
On “why is str a type if only &str is used?”
u/anlumoin r/rust • Recommends
On “str type weithout &”
u/sharddbladein r/rust • Recommends
On “why is str a type if only &str is used?”
u/kaczor647in r/rust • Recommends
On “Rust and data processing”
u/Locaritoin r/rust • Recommends
On “Should I use a Box<str> instead of a String when possible?”
u/CoffeeVectorin r/rust • Recommends
On “Should I use a Box<str> instead of a String when possible?”
u/MalbaCatoin r/rust • Recommends
On “What are the most common mistakes and code-smells that newbies make?”
u/Firakein r/rust • Mentions
On “Opinions on Lets Get Rusty?”
u/CrimsonManain r/rust • Mentions
On “Beginner code review: Convert comma-separated string to vector”
u/Ciciboy1in r/rust • Mentions
On “Help with taking borrow checker and transforming a Vec<String> to Vec<&str>”
u/Intelligent_human_1in r/rust • Mentions
On “I've been writing Rust for 5 years and I still just .clone() everything until it compiles”