-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
I tried this code:
use std::path::Path;
let path = Path::new("/foo/bar/baz/");
assert_eq!("/foo/bar/baz/", path.display().to_string());
let stripped_path = path.strip_prefix("/foo").unwrap();
println!("{}", stripped_path.display());Expected output: bar/baz/ (input with the to-strip part removed)
Actual output: bar/baz (input with the to-strip part and the trailing slash removed)
This is particularly relevant when/if #142503 lands, which further surfaces that inconsistency: playground
Meta
Reproduces in the stable and nightly builds currently on playground: 1.90.0 and 1.93.0-nightly (2025-10-28 278a909).
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.