1 unstable release

Uses new Rust 2024

1.1.2 May 9, 2018
1.1.1 Mar 29, 2017
1.0.0 Jul 17, 2016
0.1.1 Dec 1, 2025
0.1.0 Jul 14, 2016

#6 in #obsolete

Download history 227/week @ 2025-08-10 257/week @ 2025-08-17 220/week @ 2025-08-24 296/week @ 2025-08-31 257/week @ 2025-09-07 231/week @ 2025-09-14 198/week @ 2025-09-21 317/week @ 2025-09-28 184/week @ 2025-10-05 197/week @ 2025-10-12 241/week @ 2025-10-19 172/week @ 2025-10-26 103/week @ 2025-11-02 104/week @ 2025-11-09 83/week @ 2025-11-16 68/week @ 2025-11-23

375 downloads per month
Used in 9 crates (8 directly)

MIT license

2KB

File I/O 1-liners for old Rust

This crate is obsolete since Rust 1.26. If you have a file-related Rust project and would like to use this crate name, let me know!

Vec<u8>

file::get() and file::put() — read and write Vec<u8> with one function call on Rust before 1.26.

Use std::fs::read("path")? and std::fs::write("path", data)? in Rust 1.26 or later.

extern crate file;

fn example() -> file::Result<()> {
    let data = file::get("some_input_file.dat")?;
    file::put("a.out", &data)?;
    Ok(())
}

file::Result is an alias for std::io::Result. You can use Result<(), Box<std::error::Error>> in places where you don't want to expose the error type.

String

file::get_text() and file::put_text() — read and write String with one function call.

Use std::fs::read_to_string("path")? and and std::fs::write("path", string)? in Rust 1.26 or later.

extern crate file;

fn example() -> file::Result<()> {
    let string = file::get_text("hello.txt")?;
    file::put_text("bye.txt", &string)?;
    Ok(())
}

No runtime deps