typed-path icon indicating copy to clipboard operation
typed-path copied to clipboard

`TypedPathBuf::parent` documentation indicates it returns `TypedPathBuf` instead of `TypedPath`

Open rutrum opened this issue 11 months ago • 1 comments

https://docs.rs/typed-path/0.10.0/src/typed_path/typed/non_utf8/pathbuf.rs.html#549

The documentation says that the parent method returns TypedPathBuf, but it actually returns a TypedPath.

Aside from the documentation mismatch, do you know if there is a way to take &TypedPathBuf and get the parent as another TypedPathBuf?

rutrum avatar Jan 18 '25 02:01 rutrum

If you want another TypedPathBuf, you can convert the TypedPath to one.

path.parent().to_path_buf()

Alternatively, if you are okay mutating your existing TypedPathBuf, you can pop to get the parent.

path.pop();

// now it's the parent

chipsenkbeil avatar Jan 18 '25 15:01 chipsenkbeil

Fixed documentation in https://github.com/chipsenkbeil/typed-path/commit/c1e942ebc2787264caf63e6877cca947703cc70a.

chipsenkbeil avatar Jun 01 '25 00:06 chipsenkbeil