add more must_use annotations
This commit is contained in:
parent
5e38ced392
commit
2d72ee05a7
4 changed files with 9 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ use rand::{
|
|||
/// let result = connection.send(BrightnessCommand::from(b));
|
||||
/// ```
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||
#[repr(transparent)]
|
||||
pub struct Brightness(u8);
|
||||
|
||||
impl From<Brightness> for u8 {
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ impl Bitmap {
|
|||
/// pixel.set(index % 2 == 0)
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn iter_mut(&mut self) -> IterMut<u8, Msb0> {
|
||||
self.bit_vec.iter_mut()
|
||||
}
|
||||
|
|
@ -258,6 +259,7 @@ impl From<&Bitmap> for ValueGrid<bool> {
|
|||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
struct IterRows<'t> {
|
||||
bitmap: &'t Bitmap,
|
||||
row: usize,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ impl CharGrid {
|
|||
/// # use servicepoint::CharGrid;
|
||||
/// let grid = CharGrid::wrap_str(2, "abc\ndef");
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn wrap_str(width: usize, text: &str) -> Self {
|
||||
let lines = text
|
||||
.split('\n')
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ impl<T: Value> ValueGrid<T> {
|
|||
/// - height: size in y-direction
|
||||
///
|
||||
/// returns: [ValueGrid] initialized to default value.
|
||||
#[must_use]
|
||||
pub fn new(width: usize, height: usize) -> Self {
|
||||
Self {
|
||||
data: vec![Default::default(); width * height],
|
||||
|
|
@ -193,6 +194,7 @@ impl<T: Value> ValueGrid<T> {
|
|||
/// ```
|
||||
/// [Brightness]: [crate::Brightness]
|
||||
/// [Command]: [crate::Command]
|
||||
#[must_use]
|
||||
pub fn map<TConverted, F>(&self, f: F) -> ValueGrid<TConverted>
|
||||
where
|
||||
TConverted: Value,
|
||||
|
|
@ -358,11 +360,13 @@ impl<T: Value> Grid<T> for ValueGrid<T> {
|
|||
|
||||
impl<T: Value> DataRef<T> for ValueGrid<T> {
|
||||
/// Get the underlying byte rows mutable
|
||||
#[must_use]
|
||||
fn data_ref_mut(&mut self) -> &mut [T] {
|
||||
self.data.as_mut_slice()
|
||||
}
|
||||
|
||||
/// Get the underlying byte rows read only
|
||||
#[must_use]
|
||||
fn data_ref(&self) -> &[T] {
|
||||
self.data.as_slice()
|
||||
}
|
||||
|
|
@ -376,6 +380,7 @@ impl<T: Value> From<ValueGrid<T>> for Vec<T> {
|
|||
}
|
||||
|
||||
/// An iterator iver the rows in a [ValueGrid]
|
||||
#[must_use]
|
||||
pub struct IterGridRows<'t, T: Value> {
|
||||
grid: &'t ValueGrid<T>,
|
||||
row: usize,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue