diff options
| author | Sebastian Kuzminsky <seb@highlab.com> | 2024-10-23 12:55:08 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-23 18:55:08 +0000 |
| commit | 1461977cf7cf1f221d8f854ff261e7f91655bf46 (patch) | |
| tree | 2dd5dd5974c2eb79c97506fd0ddf0dca4991414b /rtic-sync/src/signal.rs | |
| parent | 00baf531808ae29873c5ff6ad528f21430ac2d0c (diff) | |
Signal ergo minor fixes (#986)
* rtic_sync::signal: fix some docs typos
* impl Debug for Signal, SignalReader, and SignalWriter
This facilitates e.g. `my_task::spawn(my_signal_reader).unwrap();`
Diffstat (limited to 'rtic-sync/src/signal.rs')
| -rw-r--r-- | rtic-sync/src/signal.rs | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/rtic-sync/src/signal.rs b/rtic-sync/src/signal.rs index 2595f6f..47a96cc 100644 --- a/rtic-sync/src/signal.rs +++ b/rtic-sync/src/signal.rs @@ -17,6 +17,18 @@ pub struct Signal<T: Copy> { store: UnsafeCell<Store<T>>, } +impl<T> core::fmt::Debug for Signal<T> +where + T: core::marker::Copy, +{ + fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + fmt.write_fmt(format_args!( + "Signal<{}>{{ .. }}", + core::any::type_name::<T>() + )) + } +} + impl<T: Copy> Default for Signal<T> { fn default() -> Self { Self::new() @@ -41,12 +53,24 @@ impl<T: Copy> Signal<T> { } } -/// Fascilitates the writing of values to a Signal. +/// Facilitates the writing of values to a Signal. #[derive(Clone)] pub struct SignalWriter<'a, T: Copy> { parent: &'a Signal<T>, } +impl<T> core::fmt::Debug for SignalWriter<'_, T> +where + T: core::marker::Copy, +{ + fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + fmt.write_fmt(format_args!( + "SignalWriter<{}>{{ .. }}", + core::any::type_name::<T>() + )) + } +} + impl<'a, T: Copy> SignalWriter<'a, T> { /// Write a raw Store value to the Signal. fn write_inner(&mut self, value: Store<T>) { @@ -69,11 +93,23 @@ impl<'a, T: Copy> SignalWriter<'a, T> { } } -/// Fascilitates the async reading of values from the Signal. +/// Facilitates the async reading of values from the Signal. pub struct SignalReader<'a, T: Copy> { parent: &'a Signal<T>, } +impl<T> core::fmt::Debug for SignalReader<'_, T> +where + T: core::marker::Copy, +{ + fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + fmt.write_fmt(format_args!( + "SignalReader<{}>{{ .. }}", + core::any::type_name::<T>() + )) + } +} + impl<'a, T: Copy> SignalReader<'a, T> { /// Immediately read and evict the latest value stored in the Signal. fn take(&mut self) -> Store<T> { |
