Skip to content

Instantly share code, notes, and snippets.

@plus7
Created January 20, 2024 22:15
Show Gist options
  • Save plus7/43edaebb2b84dc8535f566cc6bbeeec5 to your computer and use it in GitHub Desktop.
Save plus7/43edaebb2b84dc8535f566cc6bbeeec5 to your computer and use it in GitHub Desktop.
テキストファイル処理のテンプレ
use std::fs::File;
use std::io::{BufRead, BufReader};
fn main() {
let file = match File::open("test.txt") {
Err(why) => panic!("couldn't open {}: {}", "test.txt", why),
Ok(file) => file,
};
for result in BufReader::new(file).lines() {
let l = result.unwrap();
println!("{}", l);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment