←back to thread

177 points signa11 | 1 comments | | HN request time: 0s | source
Show context
kstrauser ◴[] No.42160831[source]
Rust was a pain in the ass until I stopped trying to write C code in it and started writing idiomatic Rust. I don’t know the author of this blog, but he mentions extensive C++ experience which makes me wonder if he’s trying to write C++ in Rust.

Maybe not! Maybe it’s truly just Rust being stubborn and difficult. However, it’s such an easy trap to fall into that I’ve gotta think it’s at least possible.

replies(3): >>42160844 #>>42161027 #>>42161181 #
maguirre ◴[] No.42160844[source]
Are there examples one can learn from about idiomatic rust? I would appreciate either books or projects to learn from.
replies(3): >>42160890 #>>42160891 #>>42161001 #
1. kstrauser ◴[] No.42160890[source]
https://doc.rust-lang.org/book/ is great. I’d been writing Rust for months before I started reading it and still began learning new things from the start. Oh, that’s why it does this!

Edit: Oh! And use “cargo clippy” regularly. It makes excellent recommendations for how to make your code more idiomatic, with links to docs explaining why it’s nicer that way.