[librsvg: 8/10] Don't create a LengthFoo::from_cssparser; we already create ::parse
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 8/10] Don't create a LengthFoo::from_cssparser; we already create ::parse
- Date: Wed, 13 Nov 2019 03:38:56 +0000 (UTC)
commit d8e26cb4f434b15fe0e4e5d742dd5bdf32ec7b61
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Nov 12 18:58:26 2019 -0600
Don't create a LengthFoo::from_cssparser; we already create ::parse
rsvg_internals/src/length.rs | 25 +++++--------------------
rsvg_internals/src/property_defs.rs | 2 +-
2 files changed, 6 insertions(+), 21 deletions(-)
---
diff --git a/rsvg_internals/src/length.rs b/rsvg_internals/src/length.rs
index 13a7b49d..bb76e738 100644
--- a/rsvg_internals/src/length.rs
+++ b/rsvg_internals/src/length.rs
@@ -163,9 +163,11 @@ pub trait LengthTrait: Sized {
/// Returns `self` if the length is >= 0, or an error.
///
- /// See the documentation for [`from_cssparser`] for an example.
+ /// ```ignore
+ /// let mut parser = Parser::new(...);
///
- /// [`from_cssparser`]: #method.from_cssparser
+ /// let length = LENGTH::parse(&mut parser).and_then($name::check_nonnegative)?;
+ /// ```
fn check_nonnegative(self) -> Result<Self, ValueErrorKind> {
if self.length() >= 0.0 {
Ok(self)
@@ -250,23 +252,6 @@ macro_rules! define_length_type {
pub fn new(length: f64, unit: LengthUnit) -> Self {
$name(Length::new(length, unit))
}
-
- /// Parses a LENGTH from a `Parser`.
- ///
- /// The result can be used together with the [`check_nonnegative`] method like
- /// this:
- ///
- /// ```ignore
- /// let mut parser = Parser::new(...);
- ///
- /// let length = LENGTH::from_cssparser(&mut parser).and_then($name::check_nonnegative)?;
- /// ```
- ///
- /// [`check_nonnegative`]: #method.check_nonnegative
- #[allow(unused)]
- pub fn from_cssparser(parser: &mut Parser<'_, '_>) -> Result<Self, ValueErrorKind> {
- Ok($name(Length::parse(parser)?))
- }
}
impl Default for $name {
@@ -500,7 +485,7 @@ fn parse_dash_array(parser: &mut Parser<'_, '_>) -> Result<Vec<LengthBoth>, Valu
let mut dasharray = Vec::new();
loop {
- dasharray.push(LengthBoth::from_cssparser(parser).and_then(LengthBoth::check_nonnegative)?);
+ dasharray.push(LengthBoth::parse(parser).and_then(LengthBoth::check_nonnegative)?);
if parser.is_exhausted() {
break;
diff --git a/rsvg_internals/src/property_defs.rs b/rsvg_internals/src/property_defs.rs
index fca4bf7a..f5802b5f 100644
--- a/rsvg_internals/src/property_defs.rs
+++ b/rsvg_internals/src/property_defs.rs
@@ -72,7 +72,7 @@ make_property!(
parser.reset(&parser_state);
- Ok(BaselineShift(LengthBoth::from_cssparser(parser)?))
+ Ok(BaselineShift(LengthBoth::parse(parser)?))
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]