Unverified Commit 6841b721 authored by Bernhard Schuster's avatar Bernhard Schuster Committed by GitHub
Browse files

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 94d39bab.
parent 4685b251
Pipeline #164643 passed with stages
in 43 minutes and 41 seconds
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment