// 输出文本static LOREM_IPSUM:&'staticstr="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmodtempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodoconsequat. Duis aute irure dolor in reprehenderit in voluptate velit essecillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat nonproident, sunt in culpa qui officia deserunt mollit anim id est laborum.";use std::error::Error;use std::io::prelude::*;use std::fs::File;use std::path::Path;fnmain() {let path =Path::new("out/lorem_ipsum.txt");let display = path.display();// 用只写模式打开一个文件,并返回 `io::Result<File>` 类型letmut file =matchFile::create(&path) {Err(why) =>panic!("couldn't create {}: {}", display,Error::description(&why)),Ok(file) => file, };// 写入 `LOREM_IPSUM` 字符串到文件中, 并返回 `io::Result<()>` 类型match file.write_all(LOREM_IPSUM.as_bytes()) {Err(why) => {panic!("couldn't write to {}: {}", display,Error::description(&why)) },Ok(_) =>println!("successfully wrote to {}", display), }}