refactor(hyper): remove need for collections feature
This commit is contained in:
		| @@ -356,11 +356,21 @@ mod tests { | ||||
|  | ||||
|     use test::Bencher; | ||||
|  | ||||
|     // Slice.position_elem is unstable | ||||
|     fn index_of(slice: &[u8], byte: u8) -> Option<usize> { | ||||
|         for (index, &b) in slice.iter().enumerate() { | ||||
|             if b == byte { | ||||
|                 return Some(index); | ||||
|             } | ||||
|         } | ||||
|         None | ||||
|     } | ||||
|  | ||||
|     macro_rules! raw { | ||||
|         ($($line:expr),*) => ({ | ||||
|             [$({ | ||||
|                 let line = $line; | ||||
|                 let pos = line.position_elem(&b':').expect("raw splits on :, not found"); | ||||
|                 let pos = index_of(line, b':').expect("raw splits on ':', not found"); | ||||
|                 httparse::Header { | ||||
|                     name: ::std::str::from_utf8(&line[..pos]).unwrap(), | ||||
|                     value: &line[pos + 2..] | ||||
|   | ||||
| @@ -47,29 +47,29 @@ impl FromStr for EntityTag { | ||||
|         // Early exits: | ||||
|         // 1. The string is empty, or, | ||||
|         // 2. it doesn't terminate in a DQUOTE. | ||||
|         if slice.is_empty() || !slice.ends_with("\"") { | ||||
|         if slice.is_empty() || !slice.ends_with('"') { | ||||
|             return Err(()); | ||||
|         } | ||||
|  | ||||
|         // The etag is weak if its first char is not a DQUOTE. | ||||
|         if slice.chars().next().unwrap() == '"' /* '"' */ { | ||||
|         if slice.starts_with('"') /* '"' */ { | ||||
|             // No need to check if the last char is a DQUOTE, | ||||
|             // we already did that above. | ||||
|             if check_slice_validity(slice.slice_chars(1, length-1)) { | ||||
|             if check_slice_validity(&slice[1..length-1]) { | ||||
|                 return Ok(EntityTag { | ||||
|                     weak: false, | ||||
|                     tag: slice.slice_chars(1, length-1).to_string() | ||||
|                     tag: slice[1..length-1].to_string() | ||||
|                 }); | ||||
|             } else { | ||||
|                 return Err(()); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if slice.slice_chars(0, 3) == "W/\"" { | ||||
|             if check_slice_validity(slice.slice_chars(3, length-1)) { | ||||
|         if slice.starts_with("W/\"") { | ||||
|             if check_slice_validity(&slice[3..length-1]) { | ||||
|                 return Ok(EntityTag { | ||||
|                     weak: true, | ||||
|                     tag: slice.slice_chars(3, length-1).to_string() | ||||
|                     tag: slice[3..length-1].to_string() | ||||
|                 }); | ||||
|             } else { | ||||
|                 return Err(()); | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| #![doc(html_root_url = "https://hyperium.github.io/hyper/hyper/index.html")] | ||||
| #![feature(core, collections, io, | ||||
| #![feature(core, io, | ||||
|            box_syntax, unsafe_destructor, into_cow, convert)] | ||||
| #![deny(missing_docs)] | ||||
| #![cfg_attr(test, deny(warnings))] | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| use std::thread::{self, JoinGuard}; | ||||
| use std::sync::mpsc; | ||||
| use std::collections::VecMap; | ||||
| use net::NetworkListener; | ||||
|  | ||||
| pub struct ListenerPool<A: NetworkListener> { | ||||
| @@ -24,22 +23,16 @@ impl<'a, A: NetworkListener + Send + 'a> ListenerPool<A> { | ||||
|  | ||||
|         let (super_tx, supervisor_rx) = mpsc::channel(); | ||||
|  | ||||
|         let counter = &mut 0; | ||||
|         let work = &work; | ||||
|         let mut spawn = move || { | ||||
|             let id = *counter; | ||||
|             let guard = spawn_with(super_tx.clone(), work, self.acceptor.clone(), id); | ||||
|             *counter += 1; | ||||
|             (id, guard) | ||||
|         let spawn = move |id| { | ||||
|             spawn_with(super_tx.clone(), work, self.acceptor.clone(), id) | ||||
|         }; | ||||
|  | ||||
|         // Go | ||||
|         let mut guards: VecMap<_> = (0..threads).map(|_| spawn()).collect(); | ||||
|         let mut guards: Vec<_> = (0..threads).map(|id| spawn(id)).collect(); | ||||
|  | ||||
|         for id in supervisor_rx.iter() { | ||||
|             guards.remove(&id); | ||||
|             let (id, guard) = spawn(); | ||||
|             guards.insert(id, guard); | ||||
|             guards[id] = spawn(id); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user