From 0a1916dc64516467170338ed190076110892118f Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Thu, 2 Apr 2015 17:38:40 -0700 Subject: [PATCH] refactor(auth): adjust Scheme::scheme function to not take a marker Option --- src/header/common/authorization.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/header/common/authorization.rs b/src/header/common/authorization.rs index a8f54ea465..9ba2a04a0f 100644 --- a/src/header/common/authorization.rs +++ b/src/header/common/authorization.rs @@ -30,7 +30,7 @@ impl Header for Authorization where ::Err: 'st fn parse_header(raw: &[Vec]) -> Option> { if raw.len() == 1 { - match (from_utf8(unsafe { &raw.get_unchecked(0)[..] }), Scheme::scheme(None::)) { + match (from_utf8(unsafe { &raw.get_unchecked(0)[..] }), ::scheme()) { (Ok(header), Some(scheme)) if header.starts_with(scheme) && header.len() > scheme.len() + 1 => { header[scheme.len() + 1..].parse::().map(Authorization).ok() @@ -46,7 +46,7 @@ impl Header for Authorization where ::Err: 'st impl HeaderFormat for Authorization where ::Err: 'static { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - match Scheme::scheme(None::) { + match ::scheme() { Some(scheme) => try!(write!(fmt, "{} ", scheme)), None => () }; @@ -58,15 +58,14 @@ impl HeaderFormat for Authorization where ::Er pub trait Scheme: FromStr + fmt::Debug + Clone + Send + Sync { /// An optional Scheme name. /// - /// For example, `Basic asdf` has the name `Basic`. The Option is - /// just a marker that can be removed once UFCS is completed. - fn scheme(Option) -> Option<&'static str>; + /// Will be replaced with an associated constant once available. + fn scheme() -> Option<&'static str>; /// Format the Scheme data into a header value. fn fmt_scheme(&self, &mut fmt::Formatter) -> fmt::Result; } impl Scheme for String { - fn scheme(_: Option) -> Option<&'static str> { + fn scheme() -> Option<&'static str> { None } @@ -86,7 +85,7 @@ pub struct Basic { } impl Scheme for Basic { - fn scheme(_: Option) -> Option<&'static str> { + fn scheme() -> Option<&'static str> { Some("Basic") }