Skip to content

Commit

Permalink
Rollup merge of rust-lang#40682 - TigleyM:str_doc, r=steveklabnik
Browse files Browse the repository at this point in the history
Update docs for std::str

fixes rust-lang#29375

I noticed there are docs for the `str` primitive type, which contained extensive examples, so my additions give a more general explanation of `&str`. But please let me know if something can be explained more or changed.

r? @steveklabnik
  • Loading branch information
frewsxcv authored Mar 29, 2017
2 parents 07a3429 + da74e86 commit 378d230
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,28 @@

//! Unicode string slices.
//!
//! The `&str` type is one of the two main string types, the other being `String`.
//! Unlike its `String` counterpart, its contents are borrowed.
//!
//! # Basic Usage
//!
//! A basic string declaration of `&str` type:
//!
//! ```
//! let hello_world = "Hello, World!";
//! ```
//!
//! Here we have declared a string literal, also known as a string slice.
//! String literals have a static lifetime, which means the string `hello_world`
//! is guaranteed to be valid for the duration of the entire program.
//! We can explicitly specify `hello_world`'s lifetime as well:
//!
//! ```
//! let hello_world: &'static str = "Hello, world!";
//! ```
//!
//! *[See also the `str` primitive type](../../std/primitive.str.html).*


#![stable(feature = "rust1", since = "1.0.0")]

// Many of the usings in this module are only used in the test configuration.
Expand Down

0 comments on commit 378d230

Please sign in to comment.