-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manipulating path segments #188
Comments
In the meantime, what's the right way to add path segments? Something like
? |
I guess it would actually need to check if |
Yes, something like that. |
I guess the current issue is related so I am posting here. Let me know if I should open a new issue. I am trying to switch to let mut path = url.path_mut().unwrap();
path.push(segment.to_owned()); I am trying to append a segment to a path which doesn't end with a trailing Thanks |
In 1.0.0 you have to use string concatenation and |
The example by @sfackler doens't appear to work, you'd have to create a
|
Yeah, for now you have to move the The API I have in mind would be something like this: impl Url {
fn path_segments_mut(&mut self) -> PathSegmentsMut { … }
}
struct PathSegmentsMut<'a> {
url: &'a mut Url
}
impl<'a> PathSegmentsMut<'a> {
fn iter(&self) -> PathSegments { … }
fn clear(&mut self) { … }
fn pop(&mut self) { … }
fn push(&mut self, s: &str) { … }
} |
Add Url::path_segments_mut, fix #188 @sfackler @maximih @jgillich How does this look? Would these new API help for your use cases? Can they be improved? @nox, please review and but don’t land yet. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/194) <!-- Reviewable:end -->
Url
currently haspop_path_segments
andpush_path_segment
methods, but they have a design problem reported by @sfackler. A path is at minimum/
which is considered like a single path segment that happens to be empty (like trailing slashes in general), sopush_path_segment("foo")
make the path be//foo
with two slashes.Fixing this may involve breaking API changes, so instead I’ll make these methods private (effectively removing them) before publishing 1.0.0, in order to unblock it. I’ll add them back (or something else to provide this functionality) in 1.1.0.
The text was updated successfully, but these errors were encountered: