[[!tag learning-rust]]

  • Python is a "batteris included" language: the standard library that comes with a standard Python installation is quite large. Rust's is not as large, but that's OK: Cargo makes it easy to use third-party libraries (or so they say). Still, the Rust stdlib is large enough that an overview is good.

  • The API of an abstract type, such as a Vec, is not as simple as for, say, C or Python. That's because Rust has constraints on types for some methods. For example, a method for sorting is only defined for vectors of types that can be ordered. This makes the stdlib much more powerful, and allows it to include a lot more functionality than would be obvious from first glance, but does seem to me to make it harder to navigate the docs, and find things.

  • So far it seems like Rust's stdlib is good, but concentrates on giving building blocks for doing higher level things, rather than implementing such higher level things itself. The stdlib aims to be (and remaind) stable, not provide everything. This is probably good. A firm, stable base on which to build things.

  • Slices and vectors are very closely related, but this is not because there's hardcoded magic in the language, but rather the language provides tools for implementing this. Contrast with C's pointers vs arrays, which is deeply hardcoded into the language.

  • Methods one might expect for a container may be in an iterators instead. Interesting design choice. I should study the iterator methods.

  • There seems to be a lot of traits, and it will take some time to get familiar with them all. A bit of a labyrinth.

  • I don't understand where HashSet in the "Here's a shortcut, just as we defined for vectors" example comes from. Indeed, clicking on the play button shows errors. Maybe it's meant to expand on previous examples.

  • "If both the struct and the trait came from the same crate (particularly, the stdlib) then such implemention would not be allowed." I wonder if that should say "from different crates"?