Skip to content

Commit

Permalink
cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoods committed Dec 7, 2024
1 parent 6d6e28a commit 3918995
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 28 deletions.
2 changes: 1 addition & 1 deletion composable-architecture/src/dependencies/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl<T> Default for Dependency<T> {
/// - The methods of `Dependency` are very similar to those of [`std::option::Option`], as
/// dependencies are *optionally* present.
/// - However, a `Dependency` on a type with a [`DependencyDefault`] also implements the
/// [`AsRef`], [`Deref`] and [`Borrow`] traits. Event if a value has not been explicitly
/// [`AsRef`], [`Deref`] and [`Borrow`] traits. Even if a value has not been explicitly
/// registered for it, the `Dependency` will still be able to [`as_ref`], [`deref`] and
/// [`borrow`] this default value.
///
Expand Down
1 change: 0 additions & 1 deletion composable-views/src/gesture/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ mod tap;

pub use tap::{TapGesture, Target};


#[non_exhaustive] // must use `State::default()`
#[derive(Copy, Clone, Default, Eq, PartialEq)]
pub struct Values {
Expand Down
2 changes: 1 addition & 1 deletion composable-views/src/gesture/tap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ impl<V: View> View for Target<V> {
fn draw(&self, bounds: Bounds, onto: &mut impl Output) {
self.view.draw(bounds, onto)
}
}
}
7 changes: 3 additions & 4 deletions composable-views/src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,12 @@ impl View for () {
}

#[inline(always)]
fn event(&self, event: Event, offset: Point, bounds: Bounds) {}
fn event(&self, _event: Event, _offset: Point, _bounds: Bounds) {}

#[inline(always)]
fn draw(&self, bounds: Bounds, onto: &mut impl Output) {}
fn draw(&self, _bounds: Bounds, _onto: &mut impl Output) {}
}


impl<T: View, const N: usize> View for Horizontal<[T; N]> {
#[inline]
fn size(&self) -> Size {
Expand Down Expand Up @@ -245,4 +244,4 @@ impl<V: View, const N: usize> Layout for [V; N] {
fn across(self) -> impl View {
Horizontal(self)
}
}
}
9 changes: 1 addition & 8 deletions composable-views/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,7 @@ pub trait View: Sized {
self
}


fn on_tap<A, E>(
self,
id: Id,
action: A,
send: E,
) -> TapGesture<Self, A, E>
fn on_tap<A, E>(self, id: Id, action: A, send: E) -> TapGesture<Self, A, E>
where
A: Clone,
E: Effects<A>,
Expand All @@ -157,7 +151,6 @@ pub trait View: Sized {
}
}


fn on_tap_target<A, E>(
self,
id: Id,
Expand Down
3 changes: 2 additions & 1 deletion composable-views/src/modifiers/padding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ impl<V: View> View for Padding<V> {

#[inline(always)]
fn event(&self, event: Event, offset: Point, bounds: Bounds) {
self.view.event(event, offset, bounds.inner_box(self.offsets))
self.view
.event(event, offset, bounds.inner_box(self.offsets))
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion composable-views/src/output/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Output {
}
}

impl super::Output for Output {
impl crate::Output for Output {
fn begin(&mut self, x: f32, y: f32, rgba: [u8; 4], transform: &Transform) {
if !self.data.is_empty() && (rgba != self.rgba || !transform.approx_eq(&self.transform)) {
self.end_current_node();
Expand Down
3 changes: 2 additions & 1 deletion composable-views/src/shapes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub trait Path: Sized {

/// [Least-squares approximation of the circle using cubic Bézier curves][site]
///
/// > David Ellsworth found the optimal value of c:
/// > David Ellsworth found the optimal value of c:
/// >
/// > c ≈ 0.5519703814011128603134107
///
Expand Down Expand Up @@ -177,6 +177,7 @@ impl<T: Path> View for Shape<T> {
}

#[inline(always)]
#[allow(clippy::bool_comparison)]
fn needs_layout(&self) -> bool {
self.size.get().is_finite() == false
}
Expand Down
15 changes: 6 additions & 9 deletions composable-views/src/text/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct Font<'a> {
size: f32,
}

impl<'a> Font<'a> {
impl Font<'_> {
/// Full font name that reflects all family and relevant subfamily descriptors.
#[inline]
pub fn full_name(&self) -> Option<String> {
Expand Down Expand Up @@ -78,15 +78,13 @@ impl<'a> Font<'a> {
/// Capital height,
#[inline]
pub fn capital_height(&self) -> Option<f32> {
self.face
.capital_height().map(|x| x as f32)
self.face.capital_height().map(|x| x as f32)
}

/// x height.
#[inline]
pub fn x_height(&self) -> Option<f32> {
self.face
.x_height().map(|x| x as f32)
self.face.x_height().map(|x| x as f32)
}

/// Line gap,
Expand Down Expand Up @@ -133,14 +131,14 @@ impl<'a> Font<'a> {
impl<'a> Font<'a> {
/// Create a `Font` from the raw font data.
#[inline(always)]
pub fn from(data: &'a [u8]) -> Option<FontConfig> {
pub fn from(data: &'a [u8]) -> Option<FontConfig<'a>> {
Self::from_collection(data, 0)
}

/// Create a `Font` from a font collection.
/// Returns the font at `index`, if any
#[inline(never)]
pub fn from_collection(data: &'a [u8], index: u32) -> Option<FontConfig> {
pub fn from_collection(data: &'a [u8], index: u32) -> Option<FontConfig<'a>> {
let face = Face::from_slice(data, index)?;

Some(FontConfig {
Expand Down Expand Up @@ -205,8 +203,7 @@ impl<'a> FontConfig<'a> {
///
#[inline]
pub fn variation(mut self, tag: &[u8; 4], value: f32) -> Self {
self.variations
.push((Tag::from_bytes(tag), value));
self.variations.push((Tag::from_bytes(tag), value));

self
}
Expand Down
2 changes: 1 addition & 1 deletion composable-views/src/text/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl View for Text<'_> {
rgba: [u8; 4],
}

impl<'a, F: Output> rustybuzz::ttf_parser::OutlineBuilder for Builder<'a, F> {
impl<F: Output> rustybuzz::ttf_parser::OutlineBuilder for Builder<'_, F> {
fn move_to(&mut self, x: f32, y: f32) {
self.output.begin(x, y, self.rgba, &self.transform);
}
Expand Down

0 comments on commit 3918995

Please sign in to comment.