Added default features: buffer-output, ignore-output-errors

Fortune for reverse's current commit: Half blessing − 半吉
master
Avril 2 years ago
parent 5a9edf3f5c
commit ed75b8b766
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -1,13 +1,13 @@
[package]
name = "reverse"
version = "0.2.0"
version = "0.2.1"
authors = ["Avril <flanchan@cumallover.me>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
default = ["output-lines"]
default = ["output-lines", "buffer-output", "ignore-output-errors"]
# Output as lines instead of `["2", "1", "0"]`
output-lines = []
@ -18,7 +18,8 @@ output-quoted = []
# Buffer output to conserve syscalls, useful for very large inputs (can cause higher memory usage, but generally speeds output up considerably)
buffer-output = []
# Do not attempt to handle output errors
# Do not attempt to handle output errors.
# Disable this if you are writing to a faulty device or expect some output operations to stdout to fail.
ignore-output-errors = []
[profile.release]

@ -46,11 +46,13 @@ fn collect_input() -> Box<dyn Iterator<Item=String> + 'static>
}
}
#[inline(always)]
#[cfg_attr(feature="ignore-output-errors", inline(always))]
fn handle_fmt_err<T>(res: std::io::Result<T>)
{
#[cfg(not(feature="ignore-output-errors"))]
res.expect("[!] failed to write");
#[cfg(not(feature="ignore-output-errors"))]
if let Err(e) = res {
eprintln!("[!] failed to write line: {e}");
}
let _ = res;
}
@ -82,7 +84,7 @@ fn main() {
});
}
//#[cfg(feature="buffer-output")]
handle_fmt_err(out.flush());
handle_fmt_err(out.flush()); //XXX: Do we need to flush when not buffering output? Does it matter since buffering output will be enabled by default and should almost always be enabled?
}
#[cfg(not(feature="output-lines"))]
println!("{:?}", args);

Loading…
Cancel
Save