You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-06-26 10:41:01 +02:00
More minor fixes (#1561)
- Fix compile errors and warnings in error handling example - Tweak iteration example so that it correctly visits the first grid coordinate
This commit is contained in:
@ -10,9 +10,9 @@ create custom error types that implement `From<T>`. `anyhow` helps with error
|
||||
handling in functions, including adding contextual information to your errors.
|
||||
|
||||
```rust,editable,compile_fail
|
||||
use std::{fs, io};
|
||||
use std::io::Read;
|
||||
use anyhow::{Context, Result, bail};
|
||||
use anyhow::{bail, Context, Result};
|
||||
use std::{fs, io::Read};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Clone, Debug, Eq, Error, PartialEq)]
|
||||
#[error("Found no username in {0}")]
|
||||
@ -25,7 +25,7 @@ fn read_username(path: &str) -> Result<String> {
|
||||
.read_to_string(&mut username)
|
||||
.context("Failed to read")?;
|
||||
if username.is_empty() {
|
||||
bail!(EmptyUsernameError(path));
|
||||
bail!(EmptyUsernameError(path.to_string()));
|
||||
}
|
||||
Ok(username)
|
||||
}
|
||||
|
Reference in New Issue
Block a user