ごらくらいふ

プログラミングしたりゲームしたり

2018-03-05から1日間の記事一覧

Rustでホームディレクトリのファイルを読み込みたい(ドキュメントに書いてあってうれしかった話)

これ。 use std::env; use std::path::{Path, PathBuf}; use std::fs::File; use std::io::prelude::*; fn open_file() { let mut path = env::home_dir().unwrap(); path.push("config.toml"); let mut file = File::open(path).unwrap(); let mut contents…