SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use std::fs;
  2. use std::io;
  3. use std::path::Path;
  4.  
  5. pub fn copy_file<P, Q>(from: P, to: Q) -> io::Result<()>
  6. where
  7.     P: AsRef<Path>,
  8.     Q: AsRef<Path>,
  9. {
  10.     let to_buf = to.as_ref().to_path_buf();
  11.     for entry in fs::read_dir(from)? {
  12.         let entry = entry?;
  13.         let path = entry.path();
  14.         if path.is_file() {
  15.             let filename = entry.file_name().into_string();
  16.             let name = filename.unwrap();
  17.            
  18.                 fs::copy(name, to_buf.clone())?;
  19.            
  20.         }
  21.     }
  22.    
  23.  
  24.     Ok(())
  25. }
  26.  
  27.  
  28. fn main() {
  29.  
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top