MCPcopy Create free account
hub / github.com/faern/rustscript / file_to_string

Function file_to_string

src/main.rs:70–76  ·  view source on GitHub ↗
(path: P)

Source from the content-addressed store, hash-verified

68}
69
70fn file_to_string<P: AsRef<Path>>(path: P) -> Result<String> {
71 let path = path.as_ref();
72 let mut f = File::open(path).chain_err(|| format!("Unable to open {:?}", path))?;
73 let mut buffer = String::new();
74 f.read_to_string(&mut buffer).chain_err(|| "Unable to read script")?;
75 Ok(buffer)
76}
77
78fn string_to_file<P: AsRef<Path>>(path: P, data: &str) -> Result<()> {
79 let path = path.as_ref();

Callers 1

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected