4 ms·
See as someone who knows Rust fairly well. let &mut -- Essential keywords. writer = -- Duh Writer<T>
by urthor 3y ago
See as someone who knows Rust fairly well.
let &mut -- Essential keywords.
writer = -- Duh
Writer<T> -- Generic types. Important.
::writer::new -- Boilerplate.
(connection.clone()).clone; -- Relentless cloning is a big problem.
...
.unwrap -- "Consistent names for optional types," is an issue in Rust. Every module has different jargon for Some(x).
Rust certainly isn't perfect. The borrow checker creates... awkwardness, that requires .clone hacks to solve.
Flip-side is, I'm coding in CMake right now. I've had to create multiple bash scripts for manually deleting my build files and general day to day.
Software is a young profession.
Everything is shit.
- tayo42 3y agoI feel like those clones don't get enough attention. At a glance, you don't really know what those clones are doing. Is it allocating, is just increasing reference counter? Makes code hard to understand
- urthor 3y agoclone() makes an immutable, deep copy/recursive copy of the original data structure. clone() itself makes perfect sense. Why the programmer needed those clones... is a legitimate issue with Rust. In my experience so far, it's usually to hack around an interaction between the borrow checker and the output of a function constructed using dot syntax.
- dist1ll 3y ago> clone() makes an immutable, deep copy/recursive copy of the original data structure. No. clone() calls std::clone::Clone::clone. For many std collections that means deep/recursive copy. For custom data structures, it can mean anything. It depends entirely on your implementation of the Clone trait.
- oriolid 3y agoAsking as someone who has tried learning Rust but didn't get very far, doesn't unwrap essentially mean "this might panic but I don't care to implement error handling here"?
- ww520 3y agoYes, it would panic. Typically you handle the Result rather than unwrap directly.