swab
main
Implements #22.
Looks really good!
@@ -102,2 +102,4 @@
$(CC) $(CFLAGS) -o $@ src/strcmp.c
.PHONY: swab
swab: build/bin/swab
Don’t forget to add swab to the all target!
@@ -0,0 +1,72 @@
use std::{
Needs a copyright header :)
@@ -0,0 +51,4 @@
buf.resize(wordsize, 0);
loop {
match input.read(&mut buf) {
This seems cleaner to me, but it doesn’t really matter:
match input.read(&mut buf) { Ok(0) => break ExitCode::from(EX_OK as u8), Ok(v) => { if v == wordsize { let (left, right) = buf.split_at(v/2); if let Err(e) = output.write(&right) .and_then(|_| output.write(&left)) { break oserr(&argv[0], e) } } else { if let Err(e) = output.write(&buf[..v]) { break oserr(&argv[0], e) } } }, Err(e) => { if e.kind() == ErrorKind::Interrupted && force { continue } else { break oserr(&argv[0], e) } }, }
I prefer my style of mostly using the match statement.
No dependencies set.
The note is not visible to the blocked user.
Implements #22.
Looks really good!
@@ -102,2 +102,4 @@$(CC) $(CFLAGS) -o $@ src/strcmp.c.PHONY: swabswab: build/bin/swabDon’t forget to add swab to the all target!
@@ -0,0 +1,72 @@use std::{Needs a copyright header :)
@@ -0,0 +51,4 @@buf.resize(wordsize, 0);loop {match input.read(&mut buf) {This seems cleaner to me, but it doesn’t really matter:
I prefer my style of mostly using the match statement.
Pull request closed