minor doc chores (#4219)

* fix/warn: name is unused, only in debug would be used and but nobody does

* chore: Add better docs to `expansion` and why it exists

* chore: fmt

* Revert "chore: fmt"

This reverts commit 94d39bab5d1553d082a032ab6e31f579316dfa40.
This commit is contained in:
Bernhard Schuster
2021-11-04 13:53:09 +01:00
committed by GitHub
parent 6fde727c93
commit ee12f6f51a
4 changed files with 7 additions and 5 deletions
+2 -3
View File
@@ -78,7 +78,7 @@ pub fn channel<T>(
let (tx, rx) = oneshot::channel();
(
MeteredSender { name, inner: tx },
MeteredSender { inner: tx },
MeteredReceiver {
name,
inner: rx,
@@ -113,14 +113,13 @@ impl Measurable for Error {
/// Oneshot sender, created by [`channel`].
#[derive(Debug)]
pub struct MeteredSender<T> {
name: &'static str,
inner: oneshot::Sender<(Instant, T)>,
}
impl<T> MeteredSender<T> {
/// Send a value.
pub fn send(self, t: T) -> Result<(), T> {
let Self { inner, name: _ } = self;
let Self { inner } = self;
inner.send((Instant::now(), t)).map_err(|(_, t)| t)
}
@@ -23,5 +23,5 @@ assert_matches = "1.5.0"
[features]
default = []
# write the expanded version to a `overlord-expansion.rs`
# in the `cwd`
# in the `OUT_DIR` as defined by `cargo`.
expansion = []
@@ -56,7 +56,8 @@ pub(crate) fn impl_channels_out_struct(info: &OverseerInfo) -> Result<proc_macro
)*
}
#[allow(unreachable_code)] // when no defined messages in enum
#[allow(unreachable_code)]
// when no defined messages in enum
impl ChannelsOut {
/// Send a message via a bounded channel.
pub async fn send_and_log_error(
@@ -98,6 +98,8 @@ pub(crate) fn impl_overseer_gen(
additive.extend(impl_message_wrapper_enum(&info)?);
additive.extend(impl_dispatch(&info));
// Write to a file for expansion, and then use it via `include!()`
// in order to obtain better compiler errors when modifying `overlord`.
if cfg!(feature = "expansion") {
use std::io::Write;