diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-09-10 14:03:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-09-10 14:03:28 +0200 |
| commit | d3ef39f2af2301e349649189f313772f99da1b37 (patch) | |
| tree | a15794f83cd733650d7160012ca8873e6d74e3ad /src/liballoc | |
| parent | f76f2c76dc521bf0c2a337321f3d878357d5af7f (diff) | |
| parent | 3e8fadc2ac5d5e25aaf0449d50988c54be92dbe4 (diff) | |
| download | rust-d3ef39f2af2301e349649189f313772f99da1b37.tar.gz rust-d3ef39f2af2301e349649189f313772f99da1b37.zip | |
Rollup merge of #44449 - tommyip:doc_string_as_str, r=frewsxcv
Add doc example to String::as_str Fixes #44428.
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/string.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index ddb23b2ef37..1708f3e3987 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -743,6 +743,16 @@ impl String { } /// Extracts a string slice containing the entire string. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// let s = String::from("foo"); + /// + /// assert_eq!("foo", s.as_str()); + /// ``` #[inline] #[stable(feature = "string_as_str", since = "1.7.0")] pub fn as_str(&self) -> &str { |
