Skip to content

Commit 1a3459b

Browse files
committed
---
yaml --- r: 187825 b: refs/heads/tmp c: 3a96d6a h: refs/heads/master i: 187823: c135e3a v: v3
1 parent 3a7762a commit 1a3459b

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
@@ -34,5 +34,5 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: c3b77ab41c7b2802d081d788dd020961895120a7
37+
refs/heads/tmp: 3a96d6a9818fe2affc98a187fb1065120458cee9
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/tmp/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)