• coding Rust blog.rust-lang.org
    "What’s in 1.18.0 stable
    As usual, Rust 1.18.0 is a collection of improvements, cleanups, and new features.
    One of the largest changes is a long time coming: core team members Carol Nichols and Steve Klabnik have been writing a new edition of “The Rust Programming Language”, the official book about Rust. It’s being written openly on GitHub, and has over a hundred contributors in total. This release includes the first draft of the second edition in our online documentation. 19 out of 20 chapters have a draft; the draft of chapter 20 will land in Rust 1.19. When the book is done, a print version will be made available through No Starch Press, if you’d like a paper copy. We’re still working with the editors at No Starch to improve the text, but we wanted to start getting a wider audience now.
    The new edition is a complete re-write from the ground up, using the last two years of knowledge we’ve gained from teaching people Rust. You’ll find brand-new explanations for a lot of Rust’s core concepts, new projects to build, and all kinds of other good stuff. Please check it out and let us know what you think!
    As for the language itself, an old feature has learned some new tricks: the pub keyword has been expanded a bit. Experienced Rustaceans will know that items are private by default in Rust, and you can use the pub keyword to make them public. In Rust 1.18.0, pub has gained a new form:
    pub(crate) bar;
    The bit inside of () is a ‘restriction’, which refines the notion of how this is made public. Using the crate keyword like the example above means that bar would be public to the entire crate, but not outside of it. This makes it easier to declare APIs that are “public to your crate”, but not exposed to your users. This was possible with the existing module system, but often very awkward.
    You can also specify a path, like this:
    pub(in a::b::c) foo;
    This means “usable within the hierarchy of a::b::c, but not elsewhere.” This feature was defined in RFC 1422 and is documented in the reference.
    For our Windows users, Rust 1.18.0 has a new attribute, #![windows_subsystem]. It works like this:
    #![windows_subsystem(console)]
    #![windows_subsystem(windows)]
    These control the /SUBSYSTEM flag in the linker. For now, only console and windows are supported.
    When is this useful? In the simplest terms, if you’re developing a graphical application, and do not specify windows, a console window would flash up upon your application’s start. With this flag, it won’t.
    Finally, Rust’s tuples, enum variant fields, and structs (without #[repr]) have always had an undefined layout. We’ve turned on automatic re-ordering, which can result in smaller sizes through reducing padding..."

Replies (0)