Expand description
§shaddup
!
This library prevents your program from printing to stdout and stderr by using platform-specific utilities to redirect them to /dev/null (or equivalent).
By default, this will cause a compile-error if the platform is not supported,
because we don’t know how to perform the redirection.
If you’d like the library to be a no-op in these cases,
use the allow_unsupported
feature.
If you want to make this library be a no-op even if the platform is supported
(for example, for debugging),
add the no_op
feature:
this turns the entire library into a no-op.
§Usage
use shaddup::run_quietly;
let result = run_quietly(|| {
println!("This will not be printed");
eprintln!("This will also not be printed");
123
});
assert_eq!(result.unwrap(), 123);
§Features
no_op
: turns the entire library into a no-op.allow_unsupported
: turns the library into a no-op if the platform is supported (otherwise, the library will cause a compile-error).
§See also
gag
is another library that implements this functionality.
It uses a different API, based on guards
rather than closures.
It supports Unix and Windows.
Re-exports§
Modules§
Functions§
- run_
quietly - Run the given function, preventing it from printing to stdout and stderr.
- run_
quietly_ with_ opts - Run the given function, preventing it from printing to descriptors. You can customize which ones.