Skip to content

Add discoverable to_std_path_buf conversions (#64)#65

Open
chipsenkbeil wants to merge 1 commit into
mainfrom
feat/issue-64-to-std-path-buf
Open

Add discoverable to_std_path_buf conversions (#64)#65
chipsenkbeil wants to merge 1 commit into
mainfrom
feat/issue-64-to-std-path-buf

Conversation

@chipsenkbeil
Copy link
Copy Markdown
Owner

@chipsenkbeil chipsenkbeil commented May 11, 2026

Resolves #64.

Adds inherent methods on the types whose encoding is guaranteed (or runtime-resolved) to match the host platform's std::path::Path:

  • Utf8PlatformPath::as_std_path / to_std_path_buf and Utf8PlatformPathBuf::into_std_path_buf (infallible).
  • PlatformPath::to_std_path_buf_lossy (lossless on Unix-family via OsStrExt, lossy on Windows via to_string_lossy).
  • TypedPath::to_std_path_buf, TypedPathBuf::into_std_path_buf, Utf8TypedPath::to_std_path_buf, Utf8TypedPathBuf::into_std_path_buf
    • fallible, succeed only when the runtime variant matches the host.

Also adds TryFrom<Utf8TypedPathBuf> for std::path::PathBuf to mirror the existing TryFrom<TypedPathBuf> impl.

Per the design from #32, no conversion is exposed on UnixPath / WindowsPath / their UTF-8 counterparts directly. README documents the three supported patterns. No MSRV bump.

Adds inherent methods on the types whose encoding is guaranteed (or
runtime-resolved) to match the host platform's std::path::Path:

- Utf8PlatformPath::as_std_path / to_std_path_buf and
  Utf8PlatformPathBuf::into_std_path_buf (infallible).
- PlatformPath::to_std_path_buf_lossy (lossless on Unix-family via
  OsStrExt, lossy on Windows via to_string_lossy).
- TypedPath::to_std_path_buf, TypedPathBuf::into_std_path_buf,
  Utf8TypedPath::to_std_path_buf, Utf8TypedPathBuf::into_std_path_buf
  - fallible, succeed only when the runtime variant matches the host.

Also adds TryFrom<Utf8TypedPathBuf> for std::path::PathBuf to mirror
the existing TryFrom<TypedPathBuf> impl.

Per the design from #32, no conversion is exposed on UnixPath /
WindowsPath / their UTF-8 counterparts directly. README documents
the three supported patterns. No MSRV bump.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add .to_std()

1 participant