Rust 1.20 Adds Associated Contents
Rust 1.20 Adds Associated Contents
Written by Kay Ewbank   
Monday, 11 September 2017

Systems programming language Rust has been updated again to add support for associated constants. The Cargo features have also been improved.

Rust was originally sponsored by Mozilla, and is designed to be safe, fast and concurrent without having a garbage collector. Intended uses include embedding in other languages, writing programs with specific space and time requirements, and writing low-level code, like device drivers and operating systems.

The support for associated constants complements Rust's existing support for associated functions. These could be associated with traits, structs, and enums. An associated function is one that is associated with the type itself, rather than any particular instance.

Rust 1.20 adds the ability to define “associated constants” as well, so you can have code like this:

struct Struct;
impl Struct {
    const ID: u32 = 0;
}
fn main() {
    println!("the ID of Struct is: {}", Struct::ID);
}

which associates the constant ID with Struct.

Traits can also have associated constants, and those associates with traits have extra power. With a trait, you can use an associated constant in the same way you’d use an associated type: by declaring it, but not giving it a value. The implementor of the trait then declares its value upon implementation.

Cargo, Rust's package manager, has also been updated. The first change means that the crates.io secret authentication token has been moved to a location that means it can be given a permission level meaning it is hidden from other users on your system. Prior to this it used to be stored in the configuration file, meaning it would usually be stored with a permission level meaning it was world-readable.

Elsewhere in Cargo, the way secondary binaries are stored means you can keep larger binaries more separate from one another.

 rust

 

More Information

Rust Release Notes 

Rust Language Site 

Related Articles

Rust 1.16

Updated Rust Improves Documentation

Rust 1.6 Released

Rust 1.3 Released

Rust Releases New Versions

Rust Hits Stable 1.0 - So What?

Rust 1.0 Alpha Released       

Rust Reaches 0.9

Rust 0.7 Released

Rust 0.4 Full Integration of Borrowed Pointers

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, FacebookGoogle+ or Linkedin.

 

Banner


Bing Maps Improves BirdsEye Presentation
23/10/2017

There's an updated version of the Bing Maps Web Control with a number of new features. The developers describe the additions as 'smaller but highly requested'. 



Google's Fuchsia OS And The Forking Of Swift
21/11/2017

This more a "what is going on" sort of story than any prediction of the future. About a week ago the Google team developing the mysterious Fuchsia operating system forked Apple's Swift language. Now i [ ... ]


More News

 

 
 

 

blog comments powered by Disqus

 
 

   
Banner
RSS feed of news items only
I Programmer News
Copyright © 2017 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.