Exercise: concatenate file content


Write a function that received the name of two files and returns the content of the two files concatenated in both directions.

e.g. If file 1 contains "cat" and file 2 contains "dog" then return "catdog" and "dogcat"


examples/ownership/concatenate-content-of-files/src/main.rs
fn main() {
    let res = concatenate("cat.txt", "dog.txt");
    println!("{:?} {:?}", res.0, res.1);
}

fn concatenate(file1: &str, file2: &str) -> (String, String) {
    let data1 = std::fs::read_to_string(file1).unwrap();
    let data1 = data1.trim_end();
    let data2 = std::fs::read_to_string(file2).unwrap();
    let data2 = data2.trim_end();
    (format!("{data1}{data2}"), format!("{data2}{data1}"))
}