Rust programming language
source link: https://www.infoworld.com/article/3267624/whats-new-in-the-rust-language.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
The unique approach of the Rust programming language results in better code with fewer compromises than C, C++, Go, and the other languages you probably use. It also gets updated regularly, often every month.
Where to download the latest Rust version
If you already have a previous version of Rust installed via rustup
, you can access the latest version via the following command:
$ rustup update stable
Related video: Developing safer software with Rust
Get up to speed quickly on newcomer Rust, designed to create fast, system-level software. This two-minute animated explainer shows how Rust bypasses the vexing programming issues of memory and management.
The new features in Rust 1.49.0
Announced December 31, 2020, Rust 1.49.0 designates 64-bit Arm Linux as a Tier 1 target, thus providing the highest support guarantee, with the full test suite run on this platform on every change merged in the compiler. This support is expected to benefit workloads spanning from embedded systems to servers and desktops. Prebuilt binaries also are available. This marks the first time a non-x86 target has reached Tier 1 support. The Rust development team hopes to bring more platforms into this tier in the future.
Also with Rust 1.49.0, 64-bit Arm for MacOS and Windows reach Tier 2 support. Developers can expect these two targets to have prebuilt binaries installable from rustup
. Tier 2 targets are guaranteed to build, and prebuilt binaries are provided. However, the Rust team does not execute the test suite on those platforms. Produced binaries may not work and might have bugs.
Other additions, improvements, and changes in Rust 1.49.0:
- Three stable functions have been added to the library:
slice::select_nth_unstable
,slice::select_nth_unstable_by
, andslice::select_nth_unstable_by_key
. - Two library functions were made
const
:Poll::is_ready
andPoll::is_pending
. - For the language, unions now can implement
Drop
and developers now can have a field in a union withManuallyDrop<T>
. Also, uninhibited enums can be cast to integers. - Developers can bind by reference and bind by move in patterns, enabling developers to selectively borrow individual components of a type.
- For the compiler, the minimum supported version of LLVM has been moved to LLVM 9.
The new features in Rust 1.48.0
Unveiled on November 19, 2020, Rust 1.48.0 features easier linking in the Rustdoc library documentation tool, with syntax to let Rustdoc know when developers are trying to link to a type; URLs will be generated. Also in version 1.48.0:
- Developers can specify
#{doc(alias = “<alias>”) ]
on items to add search aliases when searching through the Rustdoc UI. - The
unsafe
keyword is now syntactically permitted on modules. While still rejected semantically, this can now be parsed by procedural macros. - In the compiler, the
-C link-self-contained=<yes|no>
compiler flag is stabilized. This tellsrustc
whether to link its own C runtime and libraries or rely on an external linker to find them. This is supported only onwindows-gnu
,linux-musl
, andwasi
platforms. - In the library, the
[T; N]: TryFrom<Vec<T>>
API is now stable. Developers can use it to try to turn a vector into an array of a given length. Also stabilized in this release were five other APIs:slice::as_ptr_range
,slice::as_mut_ptr_range
,VecDeque::make_contiguous
,future::pending
, andfuture::ready
. - Also in the library, all arrays of any length now implement
TryFrom<Vec<T>>
.
The new features in Rust 1.47.0
Announced October 8, 2020, Rust 1.47.0 has no new language features but enhances the standard library. Quality of life and toolchain improvements as well as library stabilizations are featured in the release. Release notes have been published for the upgrade.
Specific capabilities in Rust 1.47.0 include:
- A “const generics” feature, impacting traits on larger arrays. The feature still needs to be stabilized. Rust has lacked a way to be generic over integer values, which has caused problems with arrays. This capability is intended to address this issue and make arrays more useful.
- An upgrade to LLVM 11 compiler infrastructure, making it the default.
- Shorter backtraces, making it easier to find issues.
rustc
now supports-C control-flow-guard
, an option that will switch on the Control Flow Guard security capability on Windows. Other platforms ignore this flag.- Rustdoc now supports the Ayu theme.
- Nine APIs in the standard library were stabilized: Ident::new_raw, Range::is_empty, RangeInclusive::is_empty, Result::as_deref, Result::as_deref_mut, Vec::leak, pointer::offset_from, f32::TAU, and f64::TAU.
The new features in 1.46.0
Rust 1.46, announced on August 27, 2020, includes the following capabilities:
- Several core language features now can be used in
const fn
, includingif
,if let
,match
, and several others. - A
#[track_caller]
attribute, designed to improve error messages whenunwrap
and related functions panic, is now stable. - In a change to the library,
std::mem::forget
is now aconst fn
. Also in the library, two new APIs were stabilized:Option::zip
andvec::Drain::as_slice
. - For the compiler, the
citylib
target can be used on Apple iOS and tvOS platforms. - Recursively indexing into tuples no longer requires parentheses.
The new features in Rust 1.45.0
Announced on July 16, 2020, Rust 1.45 includes the following additions and improvements:
- A fix is offered to mend some longstanding unsoundness when casting between integers and floats.
- Stabilization is offered for function-like procedural macros in expressions, patterns, and statements. Expansion of the use of macros assists with use of the Rocket web framework for Rust.
- Several library APIs have been stabilized, such as
Arc::as_ptr
,BTreeMap::remove_entry
, andSpan::resolved_at
. The full list of APIs can be found in the Rust Blog.
The new features in Rust 1.43.1
This point release was introduced May 7, 2020, to address two regressions introduced in the 1.43.0 stable release. It also updates the OpenSSL version used by the Cargo package manager. Features include:
- Rust 1.27 introduced support for detecting x86 CPU features in the standard library, via the
is_x86_feature_detected
macro. Because of an internal refactoring, Rust 1.43.0 prevented detection of features that cannot be used on stable yet, even though detecting them previously was allowed. Version 1.43.1 fixes this regression. - A fix is offered for broken
cargo package –list
command. Rust 1.43 broke support for listing files included in packages published with Cargo, when executed inside a workspace with path dependencies or unpublished versions. - OpenSSL, a Cargo dependency, has been updated to 1.1.1g. OpenSSL had released a security advisory but the Rust team was not able to include the fix in time for Rust 1.43.0. The team has no evidence the vulnerability could compromise Cargo users’ security.
The new features in Rust 1.43.0
Announced April 23, 2020, Rust 1.43.0 was considered a fairly minor release, with no major features introduced. Changes include:
SponsoredPost Sponsored by Cisco and Intel
New advances in HCI yield big benefits
Shifting from a traditional infrastructure to HCI can open up possibilities you’ve never even dreamed of. From increasing efficiencies to lowering costs to fueling new revenue streams, learn how...
- Developers can use
item
fragments to interpolate items into the body oftrait
,impl
, andextern
blocks. - The type inference around primitives, references, and binary operations was improved.
- To help integration testing, Cargo will set some new environment variables for tests to find executables.
- In the Rust library, developers can use associated constants on floats and integers directly without having to import the module. Also, there is a new
primitive
module that re-exports Rust primitive types, which is useful when writing a macro and developers want to ensure types are not shadowed. - Several APIs in the library were stabilized:
Once::is_completed
,f32::LOG10_2
,f32::LOG2_10
,f32::LOG10_2
,f64::LOG10_2
,f64::LOG2_10
, anditer::once_with
.
The new features in Rust 1.41
Version 1.41.0, announced January 30, 2020, contains the following new features and improvements:
- Restrictions are relaxed when implementing traits. Prior to Rust 1.41.0, the orphan rule was unnecessarily strict, obstructing composition. The rule was enforced to prevent breakages when a dependency adds a new trait,
impl
, with the gist being that a traitimpl
was only permitted if either the trait or the type being implemented is local to the current crate as opposed to a foreign crate. cargo install
, for installing binary crates and Rust-based CLI tools, now will update existing installations of the crate if a new release has been published.- For lock files, which are used to ensure consistent builds, a new format is introduced to avoid unnecessary merge conflicts when changing dependencies in separate branches. The new format will be used for all new lock files while existing lock files still rely on the previous format.
- More guarantees are offered when using a
Box<T>
in FFI (Foreign Function Interface).Box<T>
, referred to as a box, provides Rust’s simplest form of heap allocation. If developers have anextern
“C” Rust function, called from C, the Rust function now can useBox<T>
for some specificT
, while usingT*
in C for the corresponding function. However, developers for now should avoid usingBox<T>
types for functions that are defined in C but invoked in Rust. In these cases, developers should directly mirror the C types as closely as possible. - Additions to the library were made, such as stabilizing the
Result::map_or
andResult:map_or_else
. Also stabilized were theweak_count
andstrong_count
methods.NonZero*
numerics now implementFrom<NonZero*>
if it is a smaller integer width. - Rust 1.41.0 will be the last version with the current level of compiler support for 32-bit Apple targets.
The new features in Rust 1.40
- It’s now possible to allow macros to themselves generate macros. This allows for far more sophisticated metaprogramming using Rust than was previously possible, except perhaps by manual code generation. It’s now also possible to use procedural macros to define types, and to use them in
extern
blocks. And the newtodo!()
macro can be used in place of the more verboseunimplemented!()
. - A new attribute,
#[non_exhaustive]
, lets you decorate a type to indicate it might have more fields or other changes in the future. This keeps other code from overriding the definition or using it as part of an exhaustive pattern match, which might break unexpectedly later on when the type is changed. - Code that would have compiled under the old borrow checker, but generates a warning under the new borrow checker, will now generate hard errors. This is both to encourage cleanup of older Rust code and to allow the old borrow checker code to be phased out entirely.
- Several new compiler targets have been added, such as ARM’s Thumb-2 Neon (version 7) and MIPS64 platforms that use the
musl
lightweight standard library.
The new features in Rust 1.38
Rust 1.38, released in September 2019, contains the following new features and improvements:
- The Cargo package manager will take advantage of pipelined compilation automatically with Rust 1.38. With pipelined compilation, the compiler does not need dependencies fully built when compiling a crate. All that is needed is their metadata, such as the list of types of dependencies. Metadata is produced early in the compilation process. Some tests have shown compilation speed increases of 10 to 20 percent for optimized, clean builds of some crate graphs.
- Linting of some incorrect uses of
mem::{unitialized, zeroed}
. With this release, the rustc compiler will provide a lint for a narrow class of incorrect initializations usingmem::uninitialized or mem::zeroed
. - Extension of the
#[deprecated]
attribute to macros. This attribute has allowed crate authors to notify users that an item of their crate is to be deprecated and removed in a future release. - Developers can use
std::any::type_name
to get the name of a type. - Stabilization of a number of functions including
<*const T>::cast
and<*mutT>::cast
.
The new features in Rust 1.37
Rust 1.37, released in August 2019, has the following new features and improvements:
- An ability to refer to
enum
variants throughtype
. Developers also can refer toenum
variants withSelf::Variant
. - The
cargo vendor
command, previously a separate crate, is now built in to the language. The command fetches project dependencies, unpacks them into the vendor/ directory, and displays the configuration snippet needed to use the vendored code during builds. - The
rustc
compiler supports profile-guided optimization, an optimizing technique for ahead-of-time compilers, via-C profile-generate
and-C profile-use
. - Developers can create unnamed
const
items.
The new features in Rust 1.36
Version 1.36 of the Rust systems programming language was released in July 2019. Rust 1.36 includes the following new features and enhancements:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK