You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I could see us having another constructor which supports this:
let from = Path::new("/foo");
let to = Path::new("/foo/bar/baz");
let path = RelativePathBuf::relative_from(from, to)?;
This is a bit tricky to implement, and there are some choices that need to be made (what does it mean to build relative from two relative paths). But it's not fundamentally out of the question.
udoprog
changed the title
Relax .relative() restriction to allow using it on regular Path
Add a RelativePathBuf constructor which can construct a relative path from two std paths
Mar 5, 2023
I second this. I just hit this problem in my code. Given a shared root, I want to calculate all RelativePaths to this root. Currently there is no other choice than to use std::PathBuf::strip_prefix, of which I'm not sure it works like I think it does.
While i tried to work around the bug, I found out that I can't use .relative() for absolute paths (which is expected):
But I belive it would be very useful if we can supply two absolute paths and get the
RelativePath
from it.The text was updated successfully, but these errors were encountered: