Skip to content

Commit 8af4b0e

Browse files
committed
---
yaml --- r: 187403 b: refs/heads/try c: 3a96d6a h: refs/heads/master i: 187401: 8437722 187399: 48f3973 v: v3
1 parent 9cb2de4 commit 8af4b0e

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: b4c965ee803a4521d8b4575f634e036f93e408f3
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 3a96d6a9818fe2affc98a187fb1065120458cee9
5-
refs/heads/try: c3b77ab41c7b2802d081d788dd020961895120a7
5+
refs/heads/try: 3a96d6a9818fe2affc98a187fb1065120458cee9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/libstd/path.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
use core::prelude::*;
109109

110110
use ascii::*;
111-
use borrow::{Borrow, ToOwned, Cow};
111+
use borrow::{Borrow, IntoCow, ToOwned, Cow};
112112
use cmp;
113113
use iter::{self, IntoIterator};
114114
use mem;
@@ -987,6 +987,18 @@ impl Borrow<Path> for PathBuf {
987987
}
988988
}
989989

990+
impl IntoCow<'static, Path> for PathBuf {
991+
fn into_cow(self) -> Cow<'static, Path> {
992+
Cow::Owned(self)
993+
}
994+
}
995+
996+
impl<'a> IntoCow<'a, Path> for &'a Path {
997+
fn into_cow(self) -> Cow<'a, Path> {
998+
Cow::Borrowed(self)
999+
}
1000+
}
1001+
9901002
impl ToOwned for Path {
9911003
type Owned = PathBuf;
9921004
fn to_owned(&self) -> PathBuf { self.to_path_buf() }
@@ -1411,6 +1423,26 @@ mod tests {
14111423
);
14121424
);
14131425

1426+
#[test]
1427+
fn into_cow() {
1428+
use borrow::{Cow, IntoCow};
1429+
1430+
let static_path = Path::new("/home/foo");
1431+
let static_cow_path: Cow<'static, Path> = static_path.into_cow();
1432+
let pathbuf = PathBuf::new("/home/foo");
1433+
1434+
{
1435+
let path: &Path = &pathbuf;
1436+
let borrowed_cow_path: Cow<Path> = path.into_cow();
1437+
1438+
assert_eq!(static_cow_path, borrowed_cow_path);
1439+
}
1440+
1441+
let owned_cow_path: Cow<'static, Path> = pathbuf.into_cow();
1442+
1443+
assert_eq!(static_cow_path, owned_cow_path);
1444+
}
1445+
14141446
#[test]
14151447
#[cfg(unix)]
14161448
pub fn test_decompositions_unix() {

0 commit comments

Comments
 (0)