Jump in the discussion.

No email address required.

Elaborate

Jump in the discussion.

No email address required.

Jump in the discussion.

No email address required.

Ah, so you deliberately chose to use a highly optimized version of Rust code to compare with random basic bitch C++ code . The equivalent Rust would be the one given above as:

pub fn read(path: &str) -> io::Result<Vec<u8>> {
    let mut file = File::open(path)?;
    let mut bytes = Vec::new();
    file.read_to_end(&mut bytes)?;
    Ok(bytes)
}

(and to answer one of your questions yes Rust is strongly typed. You are able to instantiate Vec::new(); like that without type because unlike primitive C++, the rustc compiler is able to infer the type of elements contained in the Vector at compile time because of the 'file.read_to_end(&mut bytes)' line and is able to insert that itself. If you got rid of that line the code would fail to compile because of the missing type annotation)

The correct fair comparison to what you wrote would be some optimized monstrosity from the C++ standard library. Then we can really see what's simpler.

Jump in the discussion.

No email address required.

:#marseyboar:

Jump in the discussion.

No email address required.



Link copied to clipboard
Action successful!
Error, please refresh the page and try again.