io: Improve docs on macro
Note that the docsrs build enables all features so the `impl_write` macro gets a `std` feature flag even though it is available without the `std` feature enabled. I can't think of a solution to that slight annoyance ATM. The current docs on `impl_write` seem to be stale. The macro just does a simple call through implementation of `crate::Write` and the same for `std::io::Write` if `std` is enabled. Improve the rusdocs by doing: - Remove module level docs because this is a private module and they only add minimal value. - Put the docs on the `std` macro only (docs build uses --all-features) - Explain just what the macro does and include an `# Arguments` section.
This commit is contained in:
parent
9c81d5e747
commit
71fab82a1b
|
@ -1,12 +1,7 @@
|
|||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
/// Because we cannot provide a blanket implementation of [`std::io::Write`] for all implementers
|
||||
/// of this crate's `io::Write` trait, we provide this macro instead.
|
||||
///
|
||||
/// This macro will implement `Write` given a `write` and `flush` fn, either by implementing the
|
||||
/// crate's native `io::Write` trait directly, or a more generic trait from `std` for users using
|
||||
/// that feature. In any case, this crate's `io::Write` feature will be implemented for the given
|
||||
/// type, even if indirectly.
|
||||
/// Implements [`crate::Write`] for `$ty`.
|
||||
// See below for docs (docs.rs build enables all features).
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[macro_export]
|
||||
macro_rules! impl_write {
|
||||
|
@ -24,13 +19,16 @@ macro_rules! impl_write {
|
|||
}
|
||||
}
|
||||
|
||||
/// Because we cannot provide a blanket implementation of [`std::io::Write`] for all implementers
|
||||
/// of this crate's `io::Write` trait, we provide this macro instead.
|
||||
/// Implements [`crate::Write`] for `$ty`.
|
||||
///
|
||||
/// This macro will implement `Write` given a `write` and `flush` fn, either by implementing the
|
||||
/// crate's native `io::Write` trait directly, or a more generic trait from `std` for users using
|
||||
/// that feature. In any case, this crate's `io::Write` feature will be implemented for the given
|
||||
/// type, even if indirectly.
|
||||
/// Also implements [`std::io::Write`] for `$ty` if `bitcoin_io` has the `std` feature enabled.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `$ty` - the type used to implement the two traits.
|
||||
/// * `write_fn` - the function called by the `Write::write` trait method.
|
||||
/// * `flush_fn` - the function called by the `Write::flush` trait method.
|
||||
/// * `$bounded_ty: $bounds` - optional trait bounds if required.
|
||||
#[cfg(feature = "std")]
|
||||
#[macro_export]
|
||||
macro_rules! impl_write {
|
||||
|
|
Loading…
Reference in New Issue