drumatech 0.1.9

a crate that has a little utility.
Documentation
/// the function returns file-content using given filepath
///
/// # Examples
///
/// ```
/// extern crate drumatech;
/// use drumatech::fileu;
/// let s : String = fileu::filepath_to_content("/path/to/file").unwrap();
/// ```
pub fn filepath_to_content(s: &str) -> Result<String, Box<std::error::Error>> {
    use std::fs;
    use std::path::Path;
    let mut content: String = String::new();
    if Path::new(s).exists() {
        content = fs::read_to_string(s)?;
    }
    Ok(content)
}
/// the function returns file-content or raw-strings
///
/// # Examples
///
/// ```
/// extern crate drumatech;
/// use drumatech::fileu;
/// let s : String = fileu::content_or_raw("f main(){ return 30 }");
/// assert_eq!(String::from("f main(){ return 30 }"),s);
/// ```
pub fn content_or_raw(s: &str) -> String {
    use std::fs;
    use std::path::Path;
    if Path::new(s).exists() {
        return fs::read_to_string(s).unwrap();
    }
    s.to_string()
}