Live data from Hacker News

Rust 1.48

blog.rust-lang.org

51–60 of 119 posts

Re: Rust 1.48

#51

I wish they have used a different word than `const` for "not necessarily constant but it can be called at compile time". This is bound to confuse newcomers. Note this is unrelated to this release but I just realized how confusing it could be.

Like `comptime` in Zig, I find that quite self-explanatory.

Re: Rust 1.48

#52
post #49
post #47

Earlier quoted context omitted.

TryInto is already implemented for slices in 1.47, so `let foo = u16::from_be_bytes(some_slice.try_into().unwrap());` would work before 1.48. This trait wasn't implemented for vectors though, so you would have to write `let foo = u16::from_be_bytes(some_vec.to_slice().try_into().unwrap());`. With new release you can drop `to_slice()` part. Nothing earth-shattering, but makes sense.

> TryInto is already implemented for slices in 1.47, so `let foo = u16::from_be_bytes(some_slice.try_into().unwrap());` would work before 1.48. Rustdocs say it was 1.36 even? https://doc.rust-lang.org/nightly/std/primitive.array.html#i...

Yeah, by "In 1.47" I mean that as of 1.47 it was already implemented, didn't check since which version.

Re: Rust 1.48

#53

I wish they have used a different word than `const` for "not necessarily constant but it can be called at compile time". This is bound to confuse newcomers. Note this is unrelated to this release but I just realized how confusing it could be.

Like `comptime` in Zig, I find that quite self-explanatory.

const fns are not inherently evaluated at compile time, so that would be a misnomer.

Re: Rust 1.48

#54
post #35

Earlier quoted context omitted.

I had to suffer with coworkers that would write doctests, bad docs and bad tests together at last! The solution here is to write real tests and hyperlink them in a marked up form to the functions they actually test. Coding inside of a doc string is an epic troll. This is a warning to anyone getting seduced by doctests, stay away! They invert the problem, when one should just write tests, it is a problem with the docu…

What is the distinction between a "real" test and a doc test that you're making? At least in Rust, they are the same thing.

I'd guess their coworkers decided to write all tests as doctests, rather than use doctests to ensure examples run fine?

Python's doctests are also formatted and in some ways behaving like an interactive shell session, with

    >>> code here
    output here
rather than just "literate code" so the execution context is a bit strange. This makes complicated doctests hard to inspect and debug. Doubly so because there's almost no tooling which understands doctests.

And of course on the flip side the best tests make for absolutely terrible examples since they try to exercise weird corner cases.

Re: Rust 1.48

#55

One of the things that made me so excited about Rust when I first used it was the capabilities of the Rustdoc system. The built in examples that are also unit tests, the ease of just using markdown... and now the linking is even simpler. It’s one of my favorite things about the language, and I think is why so many crates have such good documentation, because it’s easy to do. (and it’s tested and validated so you know…

I also love that it is consistent between projects. The fact that I can just go to https://docs.rs/chrono for any public project and have a consistent interface for reading and navigating is huge.

Of course this is somewhat fickle and makes competing documentation generations harder to get started but as a user when rustdoc is really good it is a nice benifit.

Re: Rust 1.48

#57
A few months ago I tried Rust but found that the tooling like auto completion and highlighting where still a bit alpha. IIRC I used VSCode with the most popular Rust plugin at the time.

Did I miss something or is there some progress being made in that respect?

Re: Rust 1.48

#58

Earlier quoted context omitted.

Like `comptime` in Zig, I find that quite self-explanatory.

const fns are not inherently evaluated at compile time, so that would be a misnomer.

Maybe `pure`. Then it is fairly straightforward to explain that the computation of `const` values must be `pure`.

Re: Rust 1.48

#59
post #50

Earlier quoted context omitted.

Go is the same. Everyone, including the stdlib maintainers seem to think a few lines of comments per method is the same as documentation on how to use the package, best practices, pitfalls, etc.

Java is the same as well

So tldr: people don't like writing documentation, and it's hard to make them care.

Re: Rust 1.48

#60

A few months ago I tried Rust but found that the tooling like auto completion and highlighting where still a bit alpha. IIRC I used VSCode with the most popular Rust plugin at the time. Did I miss something or is there some progress being made in that respect?

not sure which plugin you used but rust-analyzer is the way to go.
Post reply on HN