1
Fork 0

Rollup merge of #133419 - CromFr:add-path-strip_prefix-test-example, r=Amanieu

Added a doc test for std::path::strip_prefix

I was about 90% sure `Path::new("/test/haha/foo.txt").strip_prefix("/te")` would return an Err, but I couldn't find an example to confirm this behaviour.

This should be an easy merge :)
This commit is contained in:
Guillaume Gomez 2024-11-26 15:32:13 +01:00 committed by GitHub
commit ddb6904ee4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2504,6 +2504,7 @@ impl Path {
/// assert_eq!(path.strip_prefix("/test/haha/foo.txt/"), Ok(Path::new("")));
///
/// assert!(path.strip_prefix("test").is_err());
/// assert!(path.strip_prefix("/te").is_err());
/// assert!(path.strip_prefix("/haha").is_err());
///
/// let prefix = PathBuf::from("/test/");