Skip to content

Commit 469130d

Browse files
nhamalexcrichton
authored andcommitted
---
yaml --- r: 153964 b: refs/heads/try2 c: a0238d5 h: refs/heads/master v: v3
1 parent 963d2d0 commit 469130d

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 9956aff18a1220bc4293bc2958cd2fa9b7bb04fd
8+
refs/heads/try2: a0238d54aac73491a7b691cc8c797b23de09439c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/path/mod.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
165165
/// # Example
166166
///
167167
/// ```
168-
/// let x: &[u8] = ['f' as u8, 'o' as u8, 'o' as u8, 0];
168+
/// let x: &[u8] = b"foo\0";
169169
/// assert!(Path::new_opt(x).is_none());
170170
/// ```
171171
#[inline]
@@ -197,7 +197,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
197197
///
198198
/// ```
199199
/// let p = Path::new("abc/def");
200-
/// assert_eq!(p.as_vec(), &[97, 98, 99, 47, 100, 101, 102]);
200+
/// assert_eq!(p.as_vec(), b"abc/def");
201201
/// ```
202202
fn as_vec<'a>(&'a self) -> &'a [u8];
203203

@@ -207,7 +207,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
207207
///
208208
/// ```
209209
/// let p = Path::new("abc/def");
210-
/// assert_eq!(p.into_vec(), vec!(97, 98, 99, 47, 100, 101, 102));
210+
/// assert_eq!(p.into_vec(), b"abc/def".to_vec());
211211
/// // attempting to use p now results in "error: use of moved value"
212212
/// ```
213213
fn into_vec(self) -> Vec<u8>;
@@ -245,7 +245,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
245245
///
246246
/// ```
247247
/// let p = Path::new("abc/def/ghi");
248-
/// assert_eq!(p.dirname(), &[97, 98, 99, 47, 100, 101, 102]);
248+
/// assert_eq!(p.dirname(), b"abc/def");
249249
/// ```
250250
fn dirname<'a>(&'a self) -> &'a [u8];
251251

@@ -271,7 +271,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
271271
///
272272
/// ```
273273
/// let p = Path::new("abc/def/ghi");
274-
/// assert_eq!(p.filename(), Some(&[103, 104, 105]));
274+
/// assert_eq!(p.filename(), Some(b"ghi"));
275275
/// ```
276276
fn filename<'a>(&'a self) -> Option<&'a [u8]>;
277277

@@ -297,7 +297,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
297297
///
298298
/// ```
299299
/// let p = Path::new("/abc/def.txt");
300-
/// assert_eq!(p.filestem(), Some(&[100, 101, 102]));
300+
/// assert_eq!(p.filestem(), Some(b"def"));
301301
/// ```
302302
fn filestem<'a>(&'a self) -> Option<&'a [u8]> {
303303
match self.filename() {
@@ -336,7 +336,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
336336
///
337337
/// ```
338338
/// let p = Path::new("abc/def.txt");
339-
/// assert_eq!(p.extension(), Some(&[116, 120, 116]));
339+
/// assert_eq!(p.extension(), Some(b"txt"));
340340
/// ```
341341
fn extension<'a>(&'a self) -> Option<&'a [u8]> {
342342
match self.filename() {
@@ -458,6 +458,13 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
458458
/// byte vector or string.
459459
/// See `set_extension` for details.
460460
///
461+
/// # Example
462+
///
463+
/// ```
464+
/// let mut p = Path::new("abc/def.txt");
465+
/// assert!(p.with_extension("csv") == Path::new("abc/def.csv"));
466+
/// ```
467+
///
461468
/// # Failure
462469
///
463470
/// Fails the task if the extension contains a NUL.

0 commit comments

Comments
 (0)