Skip to content
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

Clone is not available for PathBuf<T> #5

Closed
parasyte opened this issue Feb 15, 2023 · 2 comments
Closed

Clone is not available for PathBuf<T> #5

parasyte opened this issue Feb 15, 2023 · 2 comments

Comments

@parasyte
Copy link

parasyte commented Feb 15, 2023

WindowsPathBuf and UnixPathBuf type aliases do not implement Clone due to missing trait bound requirements.

UnixEncoding and WindowsEncoding must implement Clone to satisfy the T: Clone bound in:

impl<T> Clone for PathBuf<T>
where
    T: for<'enc> Encoding<'enc> + Clone,

Minimal test case:

use typed_path::NativePathBuf;

fn main() {
    let path1 = NativePathBuf::from("hello.txt");
    let path2 = path1.clone();

    println!("{path1:?}, {path2:?}");
}

Compile error:

error[E0599]: the method `clone` exists for struct `PathBuf<WindowsEncoding>`, but its trait bounds were not satisfied
  --> src\main.rs:5:23
   |
5  |     let path2 = path1.clone();
   |                       ^^^^^ method cannot be called on `PathBuf<WindowsEncoding>` due to unsatisfied trait bounds
   |
  ::: C:\Users\jay\.cargo\registry\src\github.com-1ecc6299db9ec823\typed-path-0.2.1\src\common\non_utf8\pathbuf.rs:61:1
   |
61 | pub struct PathBuf<T>
   | --------------------- doesn't satisfy `typed_path::PathBuf<WindowsEncoding>: Clone`
   |
  ::: C:\Users\jay\.cargo\registry\src\github.com-1ecc6299db9ec823\typed-path-0.2.1\src\windows\non_utf8.rs:19:1
   |
19 | pub struct WindowsEncoding;
   | -------------------------- doesn't satisfy `WindowsEncoding: Clone`
   |
   = note: the following trait bounds were not satisfied:
           `WindowsEncoding: Clone`
           which is required by `typed_path::PathBuf<WindowsEncoding>: Clone`
@chipsenkbeil
Copy link
Owner

@parasyte can you try this with the new 0.3 release? I updated the code to be more relaxed in the clone and debug requirements, so this should make it where you can leverage clone like normal.

@parasyte
Copy link
Author

Thanks for quickly addressing this! It looks like this is no longer blocking me.

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

No branches or pull requests

2 participants