From cd1c566c8a68b097235e57267b8106ceee150e2a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 8 Apr 2020 22:44:04 -0400 Subject: error: remove the Result type alias Instead, make a local type alias that can be used within the crate, but avoid the need to export yet another symbol. --- src/component.rs | 6 +++--- src/error.rs | 2 +- src/icalendar.rs | 17 ++++++++--------- src/parser.rs | 22 +++++++++++----------- src/vcard.rs | 4 ++-- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/component.rs b/src/component.rs index f87e992..a11d38d 100644 --- a/src/component.rs +++ b/src/component.rs @@ -72,13 +72,13 @@ impl FromStr for Component { type Err = VObjectErrorKind; /// Same as `vobject::parse_component` - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> VObjectResult { parse_component(s) } } /// Parse exactly one component. Trailing data generates errors. -pub fn parse_component(s: &str) -> Result { +pub fn parse_component(s: &str) -> VObjectResult { let (rv, new_s) = read_component(s)?; if !new_s.is_empty() { let s = format!("Trailing data: `{}`", new_s); @@ -89,7 +89,7 @@ pub fn parse_component(s: &str) -> Result { } /// Parse one component and return the rest of the string. -pub fn read_component(s: &str) -> Result<(Component, &str)> { +pub fn read_component(s: &str) -> VObjectResult<(Component, &str)> { let mut parser = Parser::new(s); let rv = parser.consume_component()?; let new_s = if parser.eof() { diff --git a/src/error.rs b/src/error.rs index b9c7b3a..28f39e0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -14,4 +14,4 @@ pub enum VObjectErrorKind { ChronoError(::chrono::format::ParseError), } -pub type Result = ::std::result::Result; +pub(crate) type VObjectResult = Result; diff --git a/src/icalendar.rs b/src/icalendar.rs index c49e193..4863029 100644 --- a/src/icalendar.rs +++ b/src/icalendar.rs @@ -1,4 +1,3 @@ -use std::result::Result as RResult; use std::collections::BTreeMap; use component::Component; @@ -23,7 +22,7 @@ impl ICalendar { /// Returns an error if the parsed text is not a ICalendar (that means that an error is /// returned also if this is a valid Vcard!) /// - pub fn build(s: &str) -> Result { + pub fn build(s: &str) -> VObjectResult { let c = parse_component(s)?; Self::from_component(c).map_err(|_| VObjectErrorKind::NotAnICalendar(s.to_owned())) } @@ -45,7 +44,7 @@ impl ICalendar { } /// Wrap a Component into a Vcard object, or don't do it if the Component is not a Vcard. - pub fn from_component(c: Component)-> RResult { + pub fn from_component(c: Component)-> Result { if c.name == "VCALENDAR" { Ok(ICalendar(c)) } else { @@ -99,7 +98,7 @@ impl<'a> EventIterator<'a> { } impl<'a> Iterator for EventIterator<'a> { - type Item = RResult, &'a Component>; + type Item = Result, &'a Component>; fn next(&mut self) -> Option { self.0.next().map(Event::from_component) @@ -111,7 +110,7 @@ impl<'a> Iterator for EventIterator<'a> { pub struct Event<'a>(&'a Component); impl<'a> Event<'a> { - fn from_component(c: &'a Component) -> RResult, &'a Component> { + fn from_component(c: &'a Component) -> Result, &'a Component> { if c.name == "VEVENT" { Ok(Event(c)) } else { @@ -160,13 +159,13 @@ pub enum Time { #[cfg(feature = "timeconversions")] pub trait AsDateTime { - fn as_datetime(&self) -> Result