fix: make example code compile (useless, but why not)
This commit is contained in:
parent
79c57f4c57
commit
bed0d6b477
1 changed files with 6 additions and 4 deletions
|
@ -29,12 +29,14 @@ mydata: 123
|
|||
text text text `inline code` text text text
|
||||
|
||||
```rs
|
||||
// cargo add tokio -F macros,rt-multi-thread,fs
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
let cfg = tokio::fs::read_to_string("config.txt");
|
||||
let cfg: Vec<std::borrow::Cow<str>> = cfg.split(';').collect();
|
||||
println!(cfg.first().unwrap_or("hello".into()));
|
||||
Ok(())
|
||||
let cfg = tokio::fs::read_to_string("config.txt").await?;
|
||||
let cfg: Vec<&str> = cfg.split(';').collect();
|
||||
println!("{}", cfg.first().unwrap_or(&"hello"));
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue