The filter_map explanation is wrong. .ok() converts a result to an Option, not a boolean. Likewise, filter_map expects an option. That's how it can both filter and map.<p>Docs: <a href="https://doc.rust-lang.org/std/result/enum.Result.html#method.ok" rel="nofollow">https://doc.rust-lang.org/std/result/enum.Result.html#method...</a>
Good post, although it served to remind me again how much I love Ruby for it's emphasis on being elegant and expressive. I may not reach for it first for anymore for standing up a new service, but I still use it for personal projects and scripts unless there's a compelling reason not to.
Great post. If you are plan to write a native Ruby extension, check out Rust Helix <a href="https://usehelix.com/" rel="nofollow">https://usehelix.com/</a>
Nice article, I bookmarked it. I am just now learning Rust because I want to use an open source blockchain library/framework written in Rust. Ruby used to be my favorite language until a career in machine learning literally forced me to swap scripting languages. I also really like Haskell (plug: I wrote a Haskell book) and I find that Rust borrowed many good ideas from Haskell.
The section titled "Implicit returns and expressions" purports to contrast the two when as far as I can tell they work identically.<p>In fact, the article specifically calls out that in Rust, even if expressions have a value, which is also true in Ruby, every expression has a value (though it is sometimes nil).
> With iter(), you get a "read-only view" into the vector. After the iteration, it will be unchanged.<p>> With into_iter(), you take ownership over the vector. After the iteration, the vector will be gone. In Rust terminology, it will have moved.<p>I stopped reading right there. No Rubist or actually nobody, except real time system developers, should care about ownership.<p>It makes programming so much more complicated without any real benefit, again apart from real time systems.
Minor correction:<p>In the section about converting a vector of strings into integers the article says that the Result returned from parse() is converted to a bool via Result::ok(). However, Result::ok() actually converts the Result<T, E> into a Option<T> which is what filter_map() expects.