summaryrefslogtreecommitdiffstats
path: root/headers/src/header_components/path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'headers/src/header_components/path.rs')
-rw-r--r--headers/src/header_components/path.rs31
1 files changed, 15 insertions, 16 deletions
diff --git a/headers/src/header_components/path.rs b/headers/src/header_components/path.rs
index d6a6058..ae115fe 100644
--- a/headers/src/header_components/path.rs
+++ b/headers/src/header_components/path.rs
@@ -1,40 +1,39 @@
use soft_ascii_string::SoftAsciiChar;
-use internals::error::EncodingError;
-use internals::encoder::{EncodingWriter, EncodableInHeader};
-use ::{HeaderTryFrom, HeaderTryInto};
-use ::error::ComponentCreationError;
use super::Email;
-
+use error::ComponentCreationError;
+use internals::encoder::{EncodableInHeader, EncodingWriter};
+use internals::error::EncodingError;
+use {HeaderTryFrom, HeaderTryInto};
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub struct Path(pub Option<Email>);
impl HeaderTryFrom<Option<Email>> for Path {
fn try_from(opt_mail: Option<Email>) -> Result<Self, ComponentCreationError> {
- Ok( Path( opt_mail ) )
+ Ok(Path(opt_mail))
}
}
impl<T> HeaderTryFrom<T> for Path
- where T: HeaderTryInto<Email>
+where
+ T: HeaderTryInto<Email>,
{
fn try_from(opt_mail: T) -> Result<Self, ComponentCreationError> {
- Ok( Path( Some( opt_mail.try_into()? ) ) )
+ Ok(Path(Some(opt_mail.try_into()?)))
}
}
-impl EncodableInHeader for Path {
-
+impl EncodableInHeader for Path {
fn encode(&self, handle: &mut EncodingWriter) -> Result<(), EncodingError> {
handle.mark_fws_pos();
handle.write_char(SoftAsciiChar::from_unchecked('<'))?;
- if let Some( mail ) = self.0.as_ref() {
- mail.encode( handle )?;
+ if let Some(mail) = self.0.as_ref() {
+ mail.encode(handle)?;
}
handle.write_char(SoftAsciiChar::from_unchecked('>'))?;
handle.mark_fws_pos();
- Ok( () )
+ Ok(())
}
fn boxed_clone(&self) -> Box<EncodableInHeader> {
@@ -47,7 +46,7 @@ impl EncodableInHeader for Path {
mod test {
use super::*;
- ec_test!{empty_path, {
+ ec_test! {empty_path, {
Path( None )
} => ascii => [
MarkFWS,
@@ -55,7 +54,7 @@ mod test {
MarkFWS
]}
- ec_test!{simple_path, {
+ ec_test! {simple_path, {
Path( Some( Email::try_from( "abc@de.fg" )? ) )
} => ascii => [
MarkFWS,
@@ -70,4 +69,4 @@ mod test {
Text ">",
MarkFWS
]}
-} \ No newline at end of file
+}