Rust beginner notes & questions

As for issue #2, it’s definitely part of learning Rust. The heavy use of type inference in most Rust code makes things quite confusing for a beginner because things look a bit magical (as you hint at) until you learn what is actually going on. For iterators specifically, you can use the cloned() combinator to return values and not references (so long as the type implements Clone. To make functions abstract over owned or borrowed values, you can make use of AsRef or Borrow traits.

There are some improvements in the pipeline to make it a bit easier to work with scenarios like this: https://github.com/rust-lang/rust-roadmap/issues/17

2 Likes