Skip to content

Commit

Permalink
DOC: improves the str type explanation
Browse files Browse the repository at this point in the history
Closes #18449
  • Loading branch information
gamazeps committed Oct 31, 2014
1 parent 00cc6d2 commit 4ee0c4f
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,18 @@
//! }
//! ```
//!
//! From the example above, you can see that Rust's string literals have the
//! From the example above, you can guess that Rust's string literals have the
//! `'static` lifetime. This is akin to C's concept of a static string.
//!
//! String literals are allocated statically in the rodata of the
//! executable/library. The string then has the type `&'static str` meaning that
//! the string is valid for the `'static` lifetime, otherwise known as the
//! lifetime of the entire program. As can be inferred from the type, these static
//! strings are not mutable.
//! More precisely, string literals are immutable views with a 'static lifetime
//! (otherwise known as the lifetime of the entire program), and thus have the
//! type `&'static str`.
//!
//! # Representation
//!
//! Rust's string type, `str`, is a sequence of Unicode scalar values encoded as a
//! stream of UTF-8 bytes. All strings are guaranteed to be validly encoded UTF-8
//! sequences. Additionally, strings are not null-terminated and can contain null
//! bytes.
//! sequences. Additionally, strings are not null-terminated and can thus contain
//! null bytes.
//!
//! The actual representation of strings have direct mappings to slices: `&str`
//! is the same as `&[u8]`.
Expand Down

13 comments on commit 4ee0c4f

@bors
Copy link
Contributor

@bors bors commented on 4ee0c4f Nov 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from thestinger
at gamazeps@4ee0c4f

@bors
Copy link
Contributor

@bors bors commented on 4ee0c4f Nov 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging gamazeps/rust/issue18449 = 4ee0c4f into auto

@bors
Copy link
Contributor

@bors bors commented on 4ee0c4f Nov 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gamazeps/rust/issue18449 = 4ee0c4f merged ok, testing candidate = a5693bfc

@bors
Copy link
Contributor

@bors bors commented on 4ee0c4f Nov 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 4ee0c4f Nov 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from thestinger
at gamazeps@4ee0c4f

@bors
Copy link
Contributor

@bors bors commented on 4ee0c4f Nov 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging gamazeps/rust/issue18449 = 4ee0c4f into auto

@bors
Copy link
Contributor

@bors bors commented on 4ee0c4f Nov 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gamazeps/rust/issue18449 = 4ee0c4f merged ok, testing candidate = 342f3842

@bors
Copy link
Contributor

@bors bors commented on 4ee0c4f Nov 2, 2014

@bors
Copy link
Contributor

@bors bors commented on 4ee0c4f Nov 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from thestinger
at gamazeps@4ee0c4f

@bors
Copy link
Contributor

@bors bors commented on 4ee0c4f Nov 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging gamazeps/rust/issue18449 = 4ee0c4f into auto

@bors
Copy link
Contributor

@bors bors commented on 4ee0c4f Nov 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gamazeps/rust/issue18449 = 4ee0c4f merged ok, testing candidate = b87619e

@bors
Copy link
Contributor

@bors bors commented on 4ee0c4f Nov 3, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 4ee0c4f Nov 3, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = b87619e

Please sign in to comment.