fn read_input(input: &str) -> String {
    // The function will assume `input` is a file path. If an error occurs during reading this
    // probably means it's not a file, and it will use the input string as the text instead.

    // TODO: We should probably do some more error handling here - what if the file exists but it's
    // binary? Should we be returning an Option or Result or something?
    let res = match fs::read_to_string(input) {
        Ok(s) => s,
        Err(_) => String::from(input),
    };
    // The strings should be alphanumeric, uppercased and contain no whitespace.
    let re = regex::Regex::new(r"[^[:alnum:]]").unwrap();
    re.replace_all(&res, "").to_uppercase()
}
/// Read and preprocess input
///
/// Accepts a file path or string literal and returns an uppercased `String` containing the file
/// contents. In the event that `input` is not a valid file path, returns `input` uppercased.
///
/// # Arguments
///
/// * `input`: A string containing either a file path or some input text.
Read and preprocess input
Accepts a file path or string literal and returns an uppercased `String` containing the file
contents. In the event that `input` is not a valid file path, returns `input` uppercased.
Read and preprocess input Accepts a file path or string literal and returns an uppercased ` String ` containing the file contents . In the event that ` input ` is not a valid file path returns ` input ` uppercased .
fn read_input(input: &str) -> String {
    // The function will assume `input` is a file path. If an error occurs during reading this
    // probably means it's not a file, and it will use the input string as the text instead.
    // TODO: We should probably do some more error handling here - what if the file exists but it's
    // binary? Should we be returning an Option or Result or something?
    let res = match fs::read_to_string(input) {
        Ok(s) => s,
        Err(_) => String::from(input),
    };
    // The strings should be alphanumeric, uppercased and contain no whitespace.
    let re = regex::Regex::new(r"[^[:alnum:]]").unwrap();
    re.replace_all(&res, "").to_uppercase()
}
fn read_input ( input : & str ) -> String { // The function will assume `input` is a file path. If an error occurs during reading this // probably means it's not a file, and it will use the input string as the text instead. // TODO: We should probably do some more error handling here - what if the file exists but it's // binary? Should we be returning an Option or Result or something? let res = match fs :: read_to_string ( input ) { Ok ( s ) => s , Err ( _ ) => String :: from ( input ) , } ; // The strings should be alphanumeric, uppercased and contain no whitespace. let re = regex :: Regex :: new ( r"[^[:alnum:]]" ) . unwrap ( ) ; re . replace_all ( & res , " " ) . to_uppercase ( ) }
Read and preprocess input
Accepts a file path or string literal and returns an uppercased `String` containing the file
contents.
Read and preprocess input Accepts a file path or string literal and returns an uppercased ` String ` containing the file contents .
input
&str
input
&str