Function read_file

Source
pub fn read_file<P>(path: P) -> Result<String, Error>
where P: Into<PathBuf> + Clone,
Expand description

Reads the given file and returns its contents as a string.

§Parameters

  • path - A PathBuf or string slice containing the path to the file to be read.

§Return

A Result containing the contents of the file as a string if the file is readable, or an std::io::Error otherwise.