Live data from Hacker News

Announcing Rust 1.35.0

blog.rust-lang.org

81–90 of 111 posts

Re: Announcing Rust 1.35.0

#81
post #69

Earlier quoted context omitted.

1. It doesn't. 2. The Iterator implementation for RangeInclusive requires the underlying type to implement Step [1], which floats do not. So you can't iterate over a range of floats (although you can still construct one). [1] https://doc.rust-lang.org/nightly/std/iter/trait.Step.html

What do you mean by "it doesn't?" For example say I construct a range [INT_MIN, INT_MAX] which should have a length of 2^32. Am I prohibited from constructing this range?

You’d use the plain `Range` type for that. https://doc.rust-lang.org/std/ops/struct.Range.html

Re: Announcing Rust 1.35.0

#82

Earlier quoted context omitted.

It is a reference, yes, and without optimization, is a pointer to a value. Your parent is suggesting to not think of it in such a low-level way, and instead think of it as a permission. In this case, the pointer being optimized away makes more sense, as it’s not really about it being a pointer. I’m of two minds about it, to be honest.

If you had a Range then it would make a lot of sense. I can’t remember if Range ’s constraints on T would support that, though.

AFAIK the only constraint on `Range::contains` is that the `Idx` type conforms to `PartialOrd`. So you could in fact have a `Range` if you so desired.

Re: Announcing Rust 1.35.0

#83

Earlier quoted context omitted.

Thank your for the detailed answer. > Attempting to do it completely manually has no benefit that I can see Package managers and build tools can do basically whatever they want - run commands, execute binaries, download data, upload data, send telemetry - whatever any one of the package maintainers wants. I prefer to develop in an offline VM. When a new library is required I just download it using the host machine, c…

I found a comment on /r/rust that details the setup that one guy is using for doing Rust development in an air gapped environment. https://www.reddit.com/r/rust/comments/793evq/using_cargo_on... I do think though, that going down that route might be challenging if you try to do it the first time you are trying to develop in Rust. Furthermore, even then you are starting out with a pre-compiled toolchain and trusting q…

Don't forget, Rust is written in Rust, so if you want to compile Rust from source because you don't trust the precompiled toolchain, you're in for a very long and arduous journey all the way back to the last version of the compiler written in OCaml, and then compiling a bunch of intermediate compiler versions using the previously-compiled version to inch your way towards the current version.

I'm not even sure how many intermediate compilers you'll have to compile to do this, it will take a lot of trial-and-error due to the compiler's own sources relying on features or bugfixes from previous versions of the compiler.

Re: Announcing Rust 1.35.0

#84

Are there examples of RefMut::map_split? It seems pretty useful if it does what I think it does.

If you click the link you will be taken to the docs page. You have to then click the `+` next to the function name to expand it and show the function docs, which includes an example.

Re: Announcing Rust 1.35.0

#85
post #73

Earlier quoted context omitted.

What do you mean by "it doesn't?" For example say I construct a range [INT_MIN, INT_MAX] which should have a length of 2^32. Am I prohibited from constructing this range?

I misinterpreted your comment; I thought you meant ranges that were so large they couldn't fit in any integer type (presumably of floats). But actually, it's weirder than I thought. RangeInclusive doesn't have an inherent len() method, but one is provided by the ExactSizeIterator trait, which is implemented only when the underlying type is i8, u8, i16, or u16. len() always returns usize, regardless of the original ty…

Nice, thanks for the complete answer. It's a highly principled (and perhaps frustrating) design, in keeping with Rust's ethos.

By way of comparison, Swift overflows and returns a length of 0. Oh well.

Re: Announcing Rust 1.35.0

#86
post #73

Earlier quoted context omitted.

What do you mean by "it doesn't?" For example say I construct a range [INT_MIN, INT_MAX] which should have a length of 2^32. Am I prohibited from constructing this range?

I misinterpreted your comment; I thought you meant ranges that were so large they couldn't fit in any integer type (presumably of floats). But actually, it's weirder than I thought. RangeInclusive doesn't have an inherent len() method, but one is provided by the ExactSizeIterator trait, which is implemented only when the underlying type is i8, u8, i16, or u16. len() always returns usize, regardless of the original ty…

RangeInclusive is inclusive. This means `0..=0` has a length of 1. Therefore `0..=usize::MAX` has a length of usize::MAX + 1.

Re: Announcing Rust 1.35.0

#87

Earlier quoted context omitted.

> Part of the problem is conceptualizing this as a reference (which, admittedly, it is without optimization). Isn't that also the official name of the feature in Rust? Isn't &T in Rust pronounced "reference to T" and "&mut T" pronounced "mutable reference to T"? That is the impression I get from: https://doc.rust-lang.org/book/ch04-02-references-and-borrow...

It is a reference, yes, and without optimization, is a pointer to a value. Your parent is suggesting to not think of it in such a low-level way, and instead think of it as a permission. In this case, the pointer being optimized away makes more sense, as it’s not really about it being a pointer. I’m of two minds about it, to be honest.

Thanks for the book! A++ would read again.

https://www.amazon.com/Rust-Programming-Language-Steve-Klabn...

Re: Announcing Rust 1.35.0

#88
post #83

Earlier quoted context omitted.

I found a comment on /r/rust that details the setup that one guy is using for doing Rust development in an air gapped environment. https://www.reddit.com/r/rust/comments/793evq/using_cargo_on... I do think though, that going down that route might be challenging if you try to do it the first time you are trying to develop in Rust. Furthermore, even then you are starting out with a pre-compiled toolchain and trusting q…

Don't forget, Rust is written in Rust, so if you want to compile Rust from source because you don't trust the precompiled toolchain, you're in for a very long and arduous journey all the way back to the last version of the compiler written in OCaml, and then compiling a bunch of intermediate compiler versions using the previously-compiled version to inch your way towards the current version. I'm not even sure how man…

It’s around a thousand builds.

Re: Announcing Rust 1.35.0

#89
post #83

Earlier quoted context omitted.

Don't forget, Rust is written in Rust, so if you want to compile Rust from source because you don't trust the precompiled toolchain, you're in for a very long and arduous journey all the way back to the last version of the compiler written in OCaml, and then compiling a bunch of intermediate compiler versions using the previously-compiled version to inch your way towards the current version. I'm not even sure how man…

It’s around a thousand builds.

I'm honestly kind of surprised someone's actually gone through the effort of figuring that out, and I'm afraid to ask how long it takes to build the whole chain.

Re: Announcing Rust 1.35.0

#90
post #83

Earlier quoted context omitted.

I found a comment on /r/rust that details the setup that one guy is using for doing Rust development in an air gapped environment. https://www.reddit.com/r/rust/comments/793evq/using_cargo_on... I do think though, that going down that route might be challenging if you try to do it the first time you are trying to develop in Rust. Furthermore, even then you are starting out with a pre-compiled toolchain and trusting q…

Don't forget, Rust is written in Rust, so if you want to compile Rust from source because you don't trust the precompiled toolchain, you're in for a very long and arduous journey all the way back to the last version of the compiler written in OCaml, and then compiling a bunch of intermediate compiler versions using the previously-compiled version to inch your way towards the current version. I'm not even sure how man…

Can't you use this "alternative rust compiler. Capable of building a fully-working copy of rustc" https://github.com/thepowersgang/mrustc and a trusted C++ compiler instead?
Post reply on HN