forked from polkadot-developers/substrate-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add rs file to test syntax highlighting, add tooltips to nav icons
- Loading branch information
1 parent
14d3fdc
commit 466459a
Showing
4 changed files
with
74 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::fs::File; | ||
use std::io::prelude::*; | ||
use std::path::Path; | ||
|
||
fn main() { | ||
// Create a path to the desired file | ||
let path = Path::new("hello.txt"); | ||
let display = path.display(); | ||
|
||
// Open the path in read-only mode, returns `io::Result<File>` | ||
let mut file = match File::open(&path) { | ||
Err(why) => panic!("couldn't open {}: {}", display, why), | ||
Ok(file) => file, | ||
}; | ||
|
||
// Read the file contents into a string, returns `io::Result<usize>` | ||
let mut s = String::new(); | ||
match file.read_to_string(&mut s) { | ||
Err(why) => panic!("couldn't read {}: {}", display, why), | ||
Ok(_) => print!("{} contains:\n{}", display, s), | ||
} | ||
|
||
// `file` goes out of scope, and the "hello.txt" file gets closed | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters