wordcloud/io/file.rs
1use std::fs::File;
2use std::io;
3use std::io::Read;
4use std::path::Path;
5
6/**
7 Reads the contents of a file to a string.
8*/
9pub fn read_string_from_file(filename: &str) -> io::Result<String> {
10 let path = Path::new(filename);
11 let mut file = File::open(path)?;
12
13 let mut contents = String::new();
14 file.read_to_string(&mut contents)?;
15
16 Ok(contents)
17}