Skip to content

Commit

Permalink
fix a bunch of warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Awpteamoose committed Feb 8, 2024
1 parent 27de87a commit e061be1
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 113 deletions.
138 changes: 37 additions & 101 deletions hobo/src/create/svg.rs
Original file line number Diff line number Diff line change
@@ -1,130 +1,66 @@
use super::*;

impl Line {
#[inline]
pub fn x1(self, x1: impl num_traits::Num + std::string::ToString) -> Self {
self.set_x1(x1);
self
}

#[inline]
pub fn set_x1(&self, x1: impl num_traits::Num + std::string::ToString) {
self.set_attr(web_str::x1(), x1.to_string());
}

#[inline]
pub fn x2(self, x2: impl num_traits::Num + std::string::ToString) -> Self {
self.set_x2(x2);
self
}
#[must_use]
#[inline] pub fn x1(self, x1: impl num_traits::Num + std::string::ToString + Copy) -> Self { self.set_x1(x1); self }
#[inline] pub fn set_x1(&self, x1: impl num_traits::Num + std::string::ToString + Copy) { self.set_attr(web_str::x1(), x1.to_string()); }

#[inline]
pub fn set_x2(&self, x2: impl num_traits::Num + std::string::ToString) {
self.set_attr(web_str::x2(), x2.to_string());
}
#[must_use]
#[inline] pub fn x2(self, x2: impl num_traits::Num + std::string::ToString + Copy) -> Self { self.set_x2(x2); self }
#[inline] pub fn set_x2(&self, x2: impl num_traits::Num + std::string::ToString + Copy) { self.set_attr(web_str::x2(), x2.to_string()); }

#[inline]
pub fn y1(self, y1: impl num_traits::Num + std::string::ToString) -> Self {
self.set_y1(y1);
self
}
#[must_use]
#[inline] pub fn y1(self, y1: impl num_traits::Num + std::string::ToString + Copy) -> Self { self.set_y1(y1); self }
#[inline] pub fn set_y1(&self, y1: impl num_traits::Num + std::string::ToString + Copy) { self.set_attr(web_str::y1(), y1.to_string()); }

#[inline]
pub fn set_y1(&self, y1: impl num_traits::Num + std::string::ToString) {
self.set_attr(web_str::y1(), y1.to_string());
}

#[inline]
pub fn y2(self, y2: impl num_traits::Num + std::string::ToString) -> Self {
self.set_y2(y2);
self
}

#[inline]
pub fn set_y2(&self, y2: impl num_traits::Num + std::string::ToString) {
self.set_attr(web_str::y2(), y2.to_string());
}

#[inline]
pub fn path_length(self, path_length: impl num_traits::Num + std::string::ToString) -> Self {
self.set_path_length(path_length);
self
}
#[must_use]
#[inline] pub fn y2(self, y2: impl num_traits::Num + std::string::ToString + Copy) -> Self { self.set_y2(y2); self }
#[inline] pub fn set_y2(&self, y2: impl num_traits::Num + std::string::ToString + Copy) { self.set_attr(web_str::y2(), y2.to_string()); }

#[inline]
pub fn set_path_length(&self, path_length: impl num_traits::Num + std::string::ToString) {
self.set_attr(web_str::path_length(), path_length.to_string());
}
}
#[must_use]
#[inline] pub fn path_length(self, path_length: impl num_traits::Num + std::string::ToString + Copy) -> Self { self.set_path_length(path_length); self }
#[inline] pub fn set_path_length(&self, path_length: impl num_traits::Num + std::string::ToString + Copy) { self.set_attr(web_str::path_length(), path_length.to_string()); } }

impl Circle {
#[inline]
pub fn cx(self, cx: impl num_traits::Num + std::string::ToString) -> Self {
self.set_cx(cx);
self
}

#[inline]
pub fn set_cx(&self, cx: impl num_traits::Num + std::string::ToString) {
self.set_attr(web_str::cx(), cx.to_string());
}
#[must_use]
#[inline] pub fn cx(self, cx: impl num_traits::Num + std::string::ToString + Copy) -> Self { self.set_cx(cx); self }
#[inline] pub fn set_cx(&self, cx: impl num_traits::Num + std::string::ToString + Copy) { self.set_attr(web_str::cx(), cx.to_string()); }

#[inline]
pub fn cy(self, cy: impl num_traits::Num + std::string::ToString) -> Self {
self.set_cy(cy);
self
}
#[must_use]
#[inline] pub fn cy(self, cy: impl num_traits::Num + std::string::ToString + Copy) -> Self { self.set_cy(cy); self }
#[inline] pub fn set_cy(&self, cy: impl num_traits::Num + std::string::ToString + Copy) { self.set_attr(web_str::cy(), cy.to_string()); }

#[inline]
pub fn set_cy(&self, cy: impl num_traits::Num + std::string::ToString) {
self.set_attr(web_str::cy(), cy.to_string());
}

#[inline]
pub fn r(self, r: impl num_traits::Num + std::string::ToString) -> Self {
self.set_r(r);
self
}

#[inline]
pub fn set_r(&self, r: impl num_traits::Num + std::string::ToString) {
self.set_attr(web_str::r(), r.to_string());
}
#[must_use]
#[inline] pub fn r(self, r: impl num_traits::Num + std::string::ToString + Copy) -> Self { self.set_r(r); self }
#[inline] pub fn set_r(&self, r: impl num_traits::Num + std::string::ToString + Copy) { self.set_attr(web_str::r(), r.to_string()); }
}

impl Path {
#[inline]
pub fn d<'a>(self, d: impl Into<std::borrow::Cow<'a, str>>) -> Self {
self.set_d(d);
self
}

#[inline]
pub fn set_d<'a>(&self, d: impl Into<std::borrow::Cow<'a, str>>) {
self.set_attr(web_str::d(), d);
}
#[must_use]
#[inline] pub fn d<'a>(self, d: impl Into<std::borrow::Cow<'a, str>>) -> Self { self.set_d(d); self }
#[inline] pub fn set_d<'a>(&self, d: impl Into<std::borrow::Cow<'a, str>>) { self.set_attr(web_str::d(), d); }
}

impl Svg {
#[must_use]
#[inline]
pub fn viewbox(
self,
min_x: impl num_traits::Num + std::string::ToString,
min_y: impl num_traits::Num + std::string::ToString,
width: impl num_traits::Num + std::string::ToString,
height: impl num_traits::Num + std::string::ToString,
min_x: impl num_traits::Num + std::string::ToString + Copy,
min_y: impl num_traits::Num + std::string::ToString + Copy,
width: impl num_traits::Num + std::string::ToString + Copy,
height: impl num_traits::Num + std::string::ToString + Copy,
) -> Self {
self.set_viewbox(min_x, min_y, width, height);
self
self.set_viewbox(min_x, min_y, width, height); self
}

#[inline]
pub fn set_viewbox(
&self,
min_x: impl num_traits::Num + std::string::ToString,
min_y: impl num_traits::Num + std::string::ToString,
width: impl num_traits::Num + std::string::ToString,
height: impl num_traits::Num + std::string::ToString,
min_x: impl num_traits::Num + std::string::ToString + Copy,
min_y: impl num_traits::Num + std::string::ToString + Copy,
width: impl num_traits::Num + std::string::ToString + Copy,
height: impl num_traits::Num + std::string::ToString + Copy,
) {
self.set_attr(web_str::viewBox(), format!("{} {} {} {}", min_x.to_string(), min_y.to_string(), width.to_string(), height.to_string()));
}
Expand Down
8 changes: 4 additions & 4 deletions hobo_css/src/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ impl Color {
u32::from_be_bytes([r, g, b, a])
}

pub const fn r(mut self, x: u8) -> Self { self.r = x; self }
pub const fn g(mut self, x: u8) -> Self { self.g = x; self }
pub const fn b(mut self, x: u8) -> Self { self.b = x; self }
pub const fn a(mut self, x: u8) -> Self { self.a = x; self }
#[must_use] pub const fn r(mut self, x: u8) -> Self { self.r = x; self }
#[must_use] pub const fn g(mut self, x: u8) -> Self { self.g = x; self }
#[must_use] pub const fn b(mut self, x: u8) -> Self { self.b = x; self }
#[must_use] pub const fn a(mut self, x: u8) -> Self { self.a = x; self }
}

impl From<u32> for Color {
Expand Down
4 changes: 2 additions & 2 deletions hobo_css/src/font_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ impl std::fmt::Display for FontFace {
";".fmt(f)?;
}
write!(f, "font-display:{};", self.display)?;
write!(f, "font-stretch:{} {};", &self.stretch.0, &if let Some(x) = self.stretch.1 { x } else { self.stretch.0 })?;
write!(f, "font-stretch:{} {};", &self.stretch.0, &self.stretch.1.map_or(self.stretch.0, |x| x))?;
write!(f, "font-style:{};", &self.style)?;
write!(f, "font-weight:{} {};", &self.weight.0, &if let Some(x) = self.weight.1 { x } else { self.weight.0 })?;
write!(f, "font-weight:{} {};", &self.weight.0, &self.weight.1.map_or(self.weight.0, |x| x))?;
if let Some((UnicodeRange(min, max), rest)) = self.unicode_range.split_first() {
write!(f, "unicode-range:U+{:X}", min)?;
if let Some(max) = max {
Expand Down
2 changes: 1 addition & 1 deletion hobo_css/src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ generate_properties! {

impl std::cmp::PartialOrd for Property {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
PropertyDiscriminants::from(self).partial_cmp(&PropertyDiscriminants::from(other))
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion hobo_css/src/properties/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl std::fmt::Display for TextShadowEffect {

impl crate::AppendProperty for TextShadowEffect {
fn append_property(self, properties: &mut Vec<crate::Property>) {
text_shadow::Some(vec![self]).append_property(properties)
text_shadow::Some(vec![self]).append_property(properties);
}
}

Expand Down
2 changes: 1 addition & 1 deletion hobo_css/src/properties/transform_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl TransformFunction {

impl crate::AppendProperty for TransformFunction {
fn append_property(self, properties: &mut Vec<crate::Property>) {
transform::multiple(vec![self]).append_property(properties)
transform::multiple(vec![self]).append_property(properties);
}
}

Expand Down
1 change: 1 addition & 0 deletions hobo_css/src/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ impl SelectorBuilder {
pub fn raw(self, x: String) -> Selector { Selector(vec![SelectorComponent::Raw(x)]) }
}

#[allow(clippy::return_self_not_must_use)]
#[rustfmt::skip]
impl Selector {
pub fn class(mut self, x: String) -> Self { self.0.push(SelectorComponent::Class(x)); self }
Expand Down
2 changes: 1 addition & 1 deletion hobo_css_macros/src/easy_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub fn easy_join(input: proc_macro::TokenStream) -> proc_macro::TokenStream {

// dbg!(res.to_string());

return res.into()
res.into()
}

pub fn easy_color(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
Expand Down
4 changes: 2 additions & 2 deletions hobo_css_macros/src/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct Nottable {
impl quote::ToTokens for Nottable {
fn to_tokens(&self, tokens: &mut TokenStream) {
let Self { not, stream } = self;
(quote! { Nottable { not: #not, data: MediaFeature::#stream } }).to_tokens(tokens)
(quote! { Nottable { not: #not, data: MediaFeature::#stream } }).to_tokens(tokens);
}
}

Expand Down Expand Up @@ -42,7 +42,7 @@ impl quote::ToTokens for Query {
media: Nottable { not: #media_not, data: MediaType::#media_ident },
features: vec![#(#elems),*],
}
}).to_tokens(tokens)
}).to_tokens(tokens);
}
}

Expand Down

0 comments on commit e061be1

Please sign in to comment.