Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. use std::path::{Path, PathBuf};
  2.  
  3. pub struct Example {
  4. files: Vec<PathBuf>,
  5. }
  6.  
  7. impl Example {
  8. pub fn new(files: impl IntoIterator<Item = impl Into<PathBuf>>) -> Self {
  9. Self {
  10. files: files.into_iter().map(Into::into).collect(),
  11. }
  12. }
  13. }
  14.  
  15. fn main() {
  16. Example::new(vec!["a", "b", "c"]);
  17. Example::new(vec![Path::new("a"), Path::new("b")]);
  18. Example::new(vec![PathBuf::from("a"), PathBuf::from("b")]);
  19. Example::new([1, 2, 3].iter().map(|&i| format!("file{}", i)));
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement