[go: up one dir, main page]

Function fs_extra::file::read_to_string [] [src]

pub fn read_to_string<P>(path: P) -> Result<String> where P: AsRef<Path>

Read file content, placing him into String.

Errors

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

  • This path is not a file.
  • This path file does not exist.
  • The current process does not have the permission rights to access path.

Example

    extern crate fs_extra;
    use fs_extra::file::read_to_string;

    let file_content = read_to_string("foo.txt" )?; // Get file conent from foo.txt
    println!("{}", file_content);