Read file
This commit is contained in:
parent
f9163bb683
commit
6a6d9c52e6
1 changed files with 13 additions and 2 deletions
15
src/main.rs
15
src/main.rs
|
@ -1,3 +1,14 @@
|
||||||
fn main() {
|
use std::fs::File;
|
||||||
println!("Hello, world!");
|
use std::io::Read;
|
||||||
|
|
||||||
|
fn read_file(path : &str) -> String {
|
||||||
|
let mut data = File::open(path).unwrap();
|
||||||
|
let mut buffer = String::new();
|
||||||
|
data.read_to_string(&mut buffer);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let data = read_file("test.yml");
|
||||||
|
println!("{:?}", data);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue