atanunq / viuer

Rust library for displaying images in the terminal.
MIT License
253 stars 46 forks source link

print_from_file should take AsRef<Path>, not &str #20

Closed rosekunkel closed 3 years ago

rosekunkel commented 3 years ago

Currently, if you want to pass a Path to viuer::print_from_file, you have to convert it to a &str:

let path = Path::new("some/path/foo.png");
print_from_file(path.to_str().unwrap(), &Default::default());

This isn't very ergonomic, and if your path contains invalid UTF-8, you can't use it all. Since image::io::Reader::open already takes an AsRef<Path>, I don't see any technical reason for this limitation. Additionally, str already implements AsRef<Path>, so I don't think this would be a breaking change. I'm happy to submit a pull request implementing this change, if it's wanted.

atanunq commented 3 years ago

Very good point, I don't think there is a specific reason why it is like that. I'll be happy to review/test a PR with such changes :)