File I/O in Rust (std::fs)
Në shqip: Skedarët në Rust
ShpjegimiSQ
fs::read_to_string() lexon gjithë skedarin, fs::write() e shkruan. Për skedarë të mëdhenj, BufReader::new(File::open(...)?).lines() lexon rresht pas rreshti. Të gjitha kthejnë Result.
EnglishEN
fs::read_to_string() reads a whole file, fs::write() writes one. For big files, BufReader::new(File::open(...)?).lines() reads line by line. They all return Result.
Si ta mendosh
Si të lexosh një letër menjëherë ose një libër faqe pas faqe.
Lexoje në anglisht
Like reading a note at once or a book page by page.
Shembull kodirust
let teksti = std::fs::read_to_string("notat.txt")?;
for rresht in BufReader::new(File::open("notat.txt")?).lines() {
println!("{}", rresht?);
}