Function std::fs::copyUnstable [-] [+] [src]

pub fn copy<P: AsPath + ?Sized, Q: AsPath + ?Sized>(from: &P, to: &Q) -> Result<u64>

Copies the contents of one file to another. This function will also copy the permission bits of the original file to the destination file.

This function will overwrite the contents of to.

Note that if from and to both point to the same file, then the file will likely get truncated by this operation.

Example

fn main() { use std::fs; fs::copy("foo.txt", "bar.txt"); }
use std::fs;

fs::copy("foo.txt", "bar.txt");

Errors

This function will return an error in the following situations, but is not limited to just these cases: