Programming language: Rust 1.48 maintains the documentation

Source: Heise.de added 23rd Nov 2020

  • programming-language:-rust-1.48-maintains-the-documentation

The Rust team has version 1. 48 the programming language originally created by Mozilla. After the predecessor, which appeared in October, primarily focused on the toolchain, the current release focuses on the documentation on Rustdoc. In addition, some APIs in the Rust library have been stabilized, including the attempt to convert a vector into an array with a given length.

Rustdoc is a tool that developers use to automatically create documentation for their Rust programs – analogous to Javadoc in Java -Universe. The tool rustdoc is an integral part of the Rust distribution. By default, it processes comments that start with three slashes: /// Here is a description for the following function . In addition, there is the notation //! for the so-called inner documentation, for example a Rust package (Crate) to be documented

Correctly linked The description is in Markdown format and enables the contents to be linked to one another . Until now, developers had to manually integrate and maintain the links. The current release introduces a syntax with which the documentation tool takes care of the appropriate references, as the following example from the Rust blog shows:

pub mod foo {/// Some docs for `Foo` /// /// You may want to use `Foo` with (crate :: bar :: bar). pub struct Foo; } pub mod bar {/// Some docs for `Bar` /// /// You may want to use` Bar` with [`crate::foo::Foo`]. pub struct bar; } Created for the first block rustdoc the appropriate link to Bar and vice versa for the second Link to the Foo documented above. The small difference in the syntax shows Bar as text for the upper link, but for the lower crate :: foo :: Foo .

Under another name Another addition to the documentation are so-called search aliases, which are entered via # [doc(alias = “”)] define that a search in Rustdoc for the one defined in String includes the following element:

# [doc(alias = “bar”)] struct Foo; The code specifies that when searching for “bar” the element Foo is one of the matching results. The blog post mentions the integration of C functions via the Foreign Function Interface (ffi) as an example for use in order to declare the appropriate assignment of a C library function to the corresponding Rust function.

Stable conversion With the stabilized APIs in the standard library from Rust, the conversion of a vector into an array of fixed length is particularly noteworthy. However, the transfer only works if the vector has the appropriate size, as the following example shows:

use std :: convert :: TryInto; let v1: Vec = vec! [1, 2, 3]; // This will succeed; our vector has a length of three, // we’re trying to make an array of length three. let a1: [u32; 3] = v1.try_into (). expect (“wrong length”); // But if we try to do it with a vector of length five … let v2: Vec = vec! [1, 2, 3, 4, 5]; // … this will panic, since we have the wrong length. let a2: [u32; 3] = v2.try_into (). expect (“wrong length”); The upper overpass of a A vector with three elements in a size 3 array works. In contrast, the second attempt to press a Vec with five elements into an array with three places fails . In connection with the stabilized API, the blog mentions the stabilization of Const Generics, which was initiated in the previous Rust release, and promises more information about it.

In addition, the APIs defined in the standard library apply in the current release slice :: as_ptr_range , slice :: as_mut_ptr_range , VecDeque :: make_contiguous , future :: pending and future: : ready as stable. The already stable APIs Option :: is_some , Option :: is_none , Option :: as_ref , Result :: is_ok , Result :: is_err , Result :: as_ref , Ordering :: reverse and Ordering :: then are now const .

Others Details about Rust 1. 32 can be found on the Rust blog. The full list of new features can be found in the release notes. The current version can be checked as usual with the tool rustup through install rustup update stable .

(rme)

Read the full article at Heise.de

brands: RME  
media: Heise.de  

Related posts


Notice: Undefined variable: all_related in /var/www/vhosts/rondea.com/httpdocs/wp-content/themes/rondea-2-0/single-article.php on line 88

Notice: Undefined variable: all_related in /var/www/vhosts/rondea.com/httpdocs/wp-content/themes/rondea-2-0/single-article.php on line 88

Related Products



Notice: Undefined variable: all_related in /var/www/vhosts/rondea.com/httpdocs/wp-content/themes/rondea-2-0/single-article.php on line 91

Warning: Invalid argument supplied for foreach() in /var/www/vhosts/rondea.com/httpdocs/wp-content/themes/rondea-2-0/single-article.php on line 91