Range's idiosyncrasies and the antipathy to improving its ergonomics manifest in the issues raised against the project have been a capstone mental block to my investing emotionally in Rust. I continuously really want to like the language. The premise is good, a lot of the ideas are really compelling, but when it comes down to aspects I disagree with, I get a strong sense of Rust demanding that users subjugate themsel…
My least favorite Rust type
231–240 of 298 posts
Re: My least favorite Rust type
#232Earlier quoted context omitted.
Interesting: .len() is not the length of a slice induced by the range or the distance between start and end but instead it's the len method form `ExactSizedIterator`, which in turn is a "special case" of where `Iterator.size_hint()` is known to return a correct value. The thing is `Iterator.size_hint()` does return a size, which is usize. So `Range ` can only implement `ExactSizedIterator` on 64-bit targets, which I…
This is another Rust design mistake: conflating the platform pointer size with "lengths". It's possible to process files bigger than 4 GB on 32-bit platforms. It's even possible to memory map them (using sliding windows/views). In some Rust forums, the language designers were shocked to learn that this is possible. At any rate, the Range type was very clearly designed for slices of in-memory contiguous arrays. Then t…
Who? Where? I guarantee you that the people responsible for the `usize` type, or its usage in the stdlib collections, were not shocked.
Re: My least favorite Rust type
#233Earlier quoted context omitted.
It looks like you can't. You can create a Range out of it, but the range is not an iterator. If you look at the Range docs[0], you'll see that it only implements Iterator where its generic type (A) implements std::iter::Step. Going to the Step docs[1] you'll see that its only implemented by integer types and char. If Vec implemented Step, you could iterate over it. Also, if you're referring to the "contains" guessing…
That’s what I did (at repl.it anyway)... how do I print the values in a Range of Vectors?
Re: My least favorite Rust type
#234Earlier quoted context omitted.
It looks like you can't. You can create a Range out of it, but the range is not an iterator. If you look at the Range docs[0], you'll see that it only implements Iterator where its generic type (A) implements std::iter::Step. Going to the Step docs[1] you'll see that its only implemented by integer types and char. If Vec implemented Step, you could iterate over it. Also, if you're referring to the "contains" guessing…
That’s what I did (at repl.it anyway)... how do I print the values in a Range of Vectors?
Re: My least favorite Rust type
#235Earlier quoted context omitted.
> The problem is that his/her proposal … Please just use the word “their”. “his/her” is not just awkward but also not even inclusive, as there are many people who do not use “his” or “her” pronouns.
It's sad how many cumulative hours have been lost to policing language just because some <1% of the population decided to treat their pronouns like a fashion accessory that must be as unique as possible.
Just let it go. If you don't like the comment, down vote it.
When you reply, you just create an irrelevant pointless subthread that has nothing to do with the actual post.
Yes, this applies to the parent comment too...
...but the parent comment wasn't being a dick about it.
Your comment is creating a pointless thread and being inflammatory, which is just flat out trolling.
Re: My least favorite Rust type
#236Range's idiosyncrasies and the antipathy to improving its ergonomics manifest in the issues raised against the project have been a capstone mental block to my investing emotionally in Rust. I continuously really want to like the language. The premise is good, a lot of the ideas are really compelling, but when it comes down to aspects I disagree with, I get a strong sense of Rust demanding that users subjugate themsel…
I don't know why you feel that way. Any major language or standard library change goes through an RFC process, where anyone in the community can submit feedback, and from what I have seen, the official teams are very responsive to concerns.
Re: My least favorite Rust type
#237Earlier quoted context omitted.
There are plenty of hurdles in Rust, but I wouldn't call this one of them. What exactly do you expect an Iterator for a range of vectors to do?
Traverse the entries?
Re: My least favorite Rust type
#238Earlier quoted context omitted.
There are plenty of hurdles in Rust, but I wouldn't call this one of them. What exactly do you expect an Iterator for a range of vectors to do?
Not really a Rust programmer, but I would expect a Range of vectors to operate something like a vector of Ranges. So if you say [0,10]..[20, 30], the length would be twenty, and the elements would be [1,11], [2,12]... Presumably if there was asymmetry in the values like [1,10]..[20, 50] you'd end up with...something? Not really sure what it should be, there are lots of options!
Re: My least favorite Rust type
#239Earlier quoted context omitted.
Most of the methods are constrained to types that implement PartialOrd.
Yes, but why does Rust's Range type not require this?
The reason why constraints on structs isn't a good API design is because it limits future API design scope unnecessarily. In this case, maybe you want to reuse the Range syntax as part of a DSL?
Re: My least favorite Rust type
#240Earlier quoted context omitted.
I was super excited about the idea of Rust but constantly frustrated trying to use it to write real code. I've basically decided to stay in my (ever-improving) comfort zone of C++ until Rust gets named/default arguments, which is my arbitrary litmus test for whether it's going to actually be a usable language for me.
You can do that now. Its not quite the same but pretty close: fn f(n: Option ) -> u8 { match n { Some(n0) => n0, None => 10 } } fn main() { let n1 = f(Some(20)); let n2 = f(None); println!("{} {}", n1, n2); }
1: https://dave.cheney.net/2014/10/17/functional-options-for-fr...