Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::path::{Path, PathBuf};
- pub struct Example {
- files: Vec<PathBuf>,
- }
- impl Example {
- pub fn new(files: impl IntoIterator<Item = impl Into<PathBuf>>) -> Self {
- Self {
- files: files.into_iter().map(Into::into).collect(),
- }
- }
- }
- fn main() {
- Example::new(vec!["a", "b", "c"]);
- Example::new(vec![Path::new("a"), Path::new("b")]);
- Example::new(vec![PathBuf::from("a"), PathBuf::from("b")]);
- Example::new([1, 2, 3].iter().map(|&i| format!("file{}", i)));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement