Skip to content

Commit ee89fcd

Browse files
committed
clippy
1 parent 332032f commit ee89fcd

File tree

1 file changed

+12
-6
lines changed
  • crates/punktf-lib/src/visit/deploy

1 file changed

+12
-6
lines changed

crates/punktf-lib/src/visit/deploy/mod.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,29 @@ use std::path::Path;
1616

1717
use crate::visit::{ResolvingVisitor, TemplateVisitor};
1818

19+
/// Represents the contents of a file as returned by [`safe_read`].
1920
enum SafeRead {
20-
Binary(Vec<u8>),
21+
/// File was a normal text file.
2122
String(String),
23+
24+
/// File was unable to be interpreted as a text file.
25+
Binary(Vec<u8>),
2226
}
2327

28+
/// Reads the contents of a file, first trying to interpret them as a string and if that fails
29+
/// returning the raw bytes.
2430
fn safe_read<P: AsRef<Path>>(path: P) -> io::Result<SafeRead> {
31+
/// Inner function to reduce size of monomorphization.
2532
fn inner(path: &Path) -> io::Result<SafeRead> {
2633
match std::fs::read_to_string(path) {
27-
Ok(s) => return Ok(SafeRead::String(s)),
34+
Ok(s) => Ok(SafeRead::String(s)),
2835
Err(err) if err.kind() == io::ErrorKind::InvalidData => {
29-
std::fs::read(path).map(|b| SafeRead::Binary(b))
30-
}
31-
Err(err) => {
32-
return Err(err);
36+
std::fs::read(path).map(SafeRead::Binary)
3337
}
38+
Err(err) => Err(err),
3439
}
3540
}
41+
3642
inner(path.as_ref())
3743
}
3844

0 commit comments

Comments
 (0)