Add some edge cases to the documentation of Path
Affected methods are `starts_with` and `strip_prefix`.
This commit is contained in:
@@ -1869,7 +1869,11 @@ impl Path {
|
||||
///
|
||||
/// let path = Path::new("/test/haha/foo.txt");
|
||||
///
|
||||
/// assert_eq!(path.strip_prefix("/"), Ok(Path::new("test/haha/foo.txt")));
|
||||
/// assert_eq!(path.strip_prefix("/test"), Ok(Path::new("haha/foo.txt")));
|
||||
/// assert_eq!(path.strip_prefix("/test/"), Ok(Path::new("haha/foo.txt")));
|
||||
/// assert_eq!(path.strip_prefix("/test/haha/foo.txt"), Ok(Path::new("")));
|
||||
/// assert_eq!(path.strip_prefix("/test/haha/foo.txt/"), Ok(Path::new("")));
|
||||
/// assert_eq!(path.strip_prefix("test").is_ok(), false);
|
||||
/// assert_eq!(path.strip_prefix("/haha").is_ok(), false);
|
||||
/// ```
|
||||
@@ -1900,6 +1904,9 @@ impl Path {
|
||||
/// let path = Path::new("/etc/passwd");
|
||||
///
|
||||
/// assert!(path.starts_with("/etc"));
|
||||
/// assert!(path.starts_with("/etc/"));
|
||||
/// assert!(path.starts_with("/etc/passwd"));
|
||||
/// assert!(path.starts_with("/etc/passwd/"));
|
||||
///
|
||||
/// assert!(!path.starts_with("/e"));
|
||||
/// ```
|
||||
|
||||
Reference in New Issue
Block a user