Skip to content

fix: rustup #404

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Mar 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/header/common/authorization.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::fmt;
use std::str::{FromStr, from_utf8};
use std::ops::{Deref, DerefMut};
use std::marker::Reflect;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reflect shouldn't be needed in this file as far as I can tell. What error comes up if you remove these bounds?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, since our Header traits should require Reflect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error: the trait `core::marker::Reflect` is not implemented for the type `S` [E0277]

(in lines 26 and 47)

use serialize::base64::{ToBase64, FromBase64, Standard, Config, Newline};
use header::{Header, HeaderFormat};

Expand All @@ -22,7 +23,7 @@ impl<S: Scheme> DerefMut for Authorization<S> {
}
}

impl<S: Scheme + 'static> Header for Authorization<S> where <S as FromStr>::Err: 'static {
impl<S: Scheme + Reflect + 'static> Header for Authorization<S> where <S as FromStr>::Err: 'static {
fn header_name() -> &'static str {
"Authorization"
}
Expand All @@ -43,7 +44,7 @@ impl<S: Scheme + 'static> Header for Authorization<S> where <S as FromStr>::Err:
}
}

impl<S: Scheme + 'static> HeaderFormat for Authorization<S> where <S as FromStr>::Err: 'static {
impl<S: Scheme + Reflect + 'static> HeaderFormat for Authorization<S> where <S as FromStr>::Err: 'static {
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match Scheme::scheme(None::<S>) {
Some(scheme) => try!(write!(fmt, "{} ", scheme)),
Expand Down
9 changes: 5 additions & 4 deletions src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::mem;
use std::path::Path;
use std::raw::{self, TraitObject};
use std::sync::Arc;
use std::marker::Reflect;

use openssl::ssl::{Ssl, SslStream, SslContext};
use openssl::ssl::SslVerifyMode::SslVerifyNone;
Expand Down Expand Up @@ -117,13 +118,13 @@ impl NetworkStream + Send {
impl NetworkStream + Send {
/// Is the underlying type in this trait object a T?
#[inline]
pub fn is<T: 'static>(&self) -> bool {
pub fn is<T: Reflect + 'static>(&self) -> bool {
self.get_type_id() == TypeId::of::<T>()
}

/// If the underlying type is T, get a reference to the contained data.
#[inline]
pub fn downcast_ref<T: 'static>(&self) -> Option<&T> {
pub fn downcast_ref<T: Reflect + 'static>(&self) -> Option<&T> {
if self.is::<T>() {
Some(unsafe { self.downcast_ref_unchecked() })
} else {
Expand All @@ -134,7 +135,7 @@ impl NetworkStream + Send {
/// If the underlying type is T, get a mutable reference to the contained
/// data.
#[inline]
pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T> {
pub fn downcast_mut<T: Reflect + 'static>(&mut self) -> Option<&mut T> {
if self.is::<T>() {
Some(unsafe { self.downcast_mut_unchecked() })
} else {
Expand All @@ -143,7 +144,7 @@ impl NetworkStream + Send {
}

/// If the underlying type is T, extract it.
pub fn downcast<T: 'static>(self: Box<NetworkStream + Send>)
pub fn downcast<T: Reflect + 'static>(self: Box<NetworkStream + Send>)
-> Result<Box<T>, Box<NetworkStream + Send>> {
if self.is::<T>() {
Ok(unsafe { self.downcast_unchecked() })
Expand Down
30 changes: 15 additions & 15 deletions src/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ impl FromStr for RequestUri {
type Err = HttpError;

fn from_str(s: &str) -> Result<RequestUri, HttpError> {
match s.as_bytes() {
[] => Err(HttpError::HttpUriError(UrlError::InvalidCharacter)),
[b'*'] => Ok(RequestUri::Star),
[b'/', ..] => Ok(RequestUri::AbsolutePath(s.to_string())),
bytes if bytes.contains(&b'/') => {
Ok(RequestUri::AbsoluteUri(try!(Url::parse(s))))
}
_ => {
let mut temp = "http://".to_string();
temp.push_str(s);
try!(Url::parse(&temp[..]));
todo!("compare vs u.authority()");
Ok(RequestUri::Authority(s.to_string()))
}

let bytes = s.as_bytes();
if bytes == [] {
Err(HttpError::HttpUriError(UrlError::InvalidCharacter))
} else if bytes == b"*" {
Ok(RequestUri::Star)
} else if bytes.starts_with(b"/") {
Ok(RequestUri::AbsolutePath(s.to_string()))
} else if bytes.contains(&b'/') {
Ok(RequestUri::AbsoluteUri(try!(Url::parse(s))))
} else {
let mut temp = "http://".to_string();
temp.push_str(s);
try!(Url::parse(&temp[..]));
todo!("compare vs u.authority()");
Ok(RequestUri::Authority(s.to_string()))
}
}
}
Expand Down