Skip to content

Commit 653a72f

Browse files
cleanup: fix some Clippy warnings. (#159)
* cleanup: fix some Clippy warnings. - Remove a stray doc comment. - Match a pattern rather than using `if x == y`. - Explicitly truncate newly-created files in tests/examples. - Remove an unnecessary & in a test. * oops forgot to format
1 parent eb957dd commit 653a72f

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

examples/persistent_state.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ fn create_and_store_persistent_state() -> Result<File, Box<dyn Error>> {
5555
.read(true)
5656
.write(true)
5757
.create(true)
58+
.truncate(true)
5859
.open(&path)?;
5960
fs::remove_file(&path)?;
6061

src/logging.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ static SD_SOCK: OnceCell<UnixDatagram> = OnceCell::new();
2626
const PRIORITY: ValidField = ValidField::unchecked("PRIORITY");
2727
const MESSAGE: ValidField = ValidField::unchecked("MESSAGE");
2828

29-
/// Trait for checking the type of a file descriptor.
30-
3129
/// Log priority values.
3230
///
3331
/// See `man 3 syslog`.

src/sysusers/parse.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ pub fn parse_from_reader(bufrd: &mut impl BufRead) -> Result<Vec<SysusersEntry>,
2222

2323
match data.parse() {
2424
Ok(entry) => output.push(entry),
25-
Err(SdError { kind, msg }) if kind == ErrorKind::SysusersUnknownType => {
25+
Err(SdError {
26+
kind: ErrorKind::SysusersUnknownType,
27+
msg,
28+
}) => {
2629
log::warn!("skipped line {}: {}", linenumber, msg);
2730
}
2831
Err(e) => {

tests/journal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn retry<T, E>(f: impl Fn() -> Result<T, E>) -> Result<T, E> {
4646
fn read_from_journal(test_name: &str) -> Vec<HashMap<String, String>> {
4747
let stdout = String::from_utf8(
4848
Command::new("journalctl")
49-
.args(&["--user", "--output=json"])
49+
.args(["--user", "--output=json"])
5050
// Filter by the PID of the current test process
5151
.arg(format!("_PID={}", std::process::id()))
5252
.arg(format!("TEST_NAME={}", test_name))

tests/persistent_state.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ fn create_and_store_persistent_state() -> Result<File, Box<dyn Error>> {
1717
.read(true)
1818
.write(true)
1919
.create(true)
20+
.truncate(true)
2021
.open(&path)?;
2122
fs::remove_file(&path)?;
2223

0 commit comments

Comments
 (0)