mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 01:32:57 +01:00
remove & to &mut transmute #385
This commit is contained in:
parent
82920e1ac1
commit
9aef34e768
@ -94,13 +94,13 @@ where
|
||||
self.node = Some(Node::new(el));
|
||||
let _ = match self.proto {
|
||||
Some(HttpProtocol::H1(ref mut h1)) => {
|
||||
self.node.as_ref().map(|n| h1.settings().head().insert(n))
|
||||
self.node.as_mut().map(|n| h1.settings().head().insert(n))
|
||||
}
|
||||
Some(HttpProtocol::H2(ref mut h2)) => {
|
||||
self.node.as_ref().map(|n| h2.settings().head().insert(n))
|
||||
self.node.as_mut().map(|n| h2.settings().head().insert(n))
|
||||
}
|
||||
Some(HttpProtocol::Unknown(ref mut settings, _, _, _)) => {
|
||||
self.node.as_ref().map(|n| settings.head().insert(n))
|
||||
self.node.as_mut().map(|n| settings.head().insert(n))
|
||||
}
|
||||
None => unreachable!(),
|
||||
};
|
||||
@ -188,8 +188,8 @@ where
|
||||
}
|
||||
|
||||
pub(crate) struct Node<T> {
|
||||
next: Option<*mut Node<()>>,
|
||||
prev: Option<*mut Node<()>>,
|
||||
next: Option<*mut Node<T>>,
|
||||
prev: Option<*mut Node<T>>,
|
||||
element: *mut T,
|
||||
}
|
||||
|
||||
@ -202,19 +202,18 @@ impl<T> Node<T> {
|
||||
}
|
||||
}
|
||||
|
||||
fn insert<I>(&self, next: &Node<I>) {
|
||||
fn insert<I>(&mut self, next: &mut Node<I>) {
|
||||
unsafe {
|
||||
if let Some(ref next2) = self.next {
|
||||
let n: &mut Node<()> =
|
||||
&mut *(next2.as_ref().unwrap() as *const _ as *mut _);
|
||||
n.prev = Some(next as *const _ as *mut _);
|
||||
let next: *mut Node<T> = next as *const _ as *mut _;
|
||||
|
||||
if let Some(ref mut next2) = self.next {
|
||||
let n = next2.as_mut().unwrap();
|
||||
n.prev = Some(next);
|
||||
}
|
||||
let slf: &mut Node<T> = &mut *(self as *const _ as *mut _);
|
||||
self.next = Some(next);
|
||||
|
||||
slf.next = Some(next as *const _ as *mut _);
|
||||
|
||||
let next: &mut Node<T> = &mut *(next as *const _ as *mut _);
|
||||
next.prev = Some(slf as *const _ as *mut _);
|
||||
let next: &mut Node<T> = &mut *next;
|
||||
next.prev = Some(self as *mut _);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,9 @@ use std::{env, fmt, net};
|
||||
use bytes::BytesMut;
|
||||
use futures_cpupool::CpuPool;
|
||||
use http::StatusCode;
|
||||
use lazycell::LazyCell;
|
||||
use parking_lot::Mutex;
|
||||
use time;
|
||||
use lazycell::LazyCell;
|
||||
|
||||
use super::channel::Node;
|
||||
use super::message::{Request, RequestPool};
|
||||
@ -151,7 +151,7 @@ pub(crate) struct WorkerSettings<H> {
|
||||
bytes: Rc<SharedBytesPool>,
|
||||
messages: &'static RequestPool,
|
||||
channels: Cell<usize>,
|
||||
node: Box<Node<()>>,
|
||||
node: RefCell<Node<()>>,
|
||||
date: UnsafeCell<Date>,
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ impl<H> WorkerSettings<H> {
|
||||
bytes: Rc::new(SharedBytesPool::new()),
|
||||
messages: RequestPool::pool(settings),
|
||||
channels: Cell::new(0),
|
||||
node: Box::new(Node::head()),
|
||||
node: RefCell::new(Node::head()),
|
||||
date: UnsafeCell::new(Date::new()),
|
||||
keep_alive,
|
||||
ka_enabled,
|
||||
@ -181,8 +181,8 @@ impl<H> WorkerSettings<H> {
|
||||
self.channels.get()
|
||||
}
|
||||
|
||||
pub fn head(&self) -> &Node<()> {
|
||||
&self.node
|
||||
pub fn head(&self) -> RefMut<Node<()>> {
|
||||
self.node.borrow_mut()
|
||||
}
|
||||
|
||||
pub fn handlers(&self) -> RefMut<Vec<H>> {
|
||||
|
@ -477,7 +477,7 @@ impl<H: IntoHttpHandler> HttpServer<H> {
|
||||
/// .run();
|
||||
/// }
|
||||
/// ```
|
||||
pub fn run(mut self) {
|
||||
pub fn run(self) {
|
||||
let sys = System::new("http-server");
|
||||
self.start();
|
||||
sys.run();
|
||||
|
Loading…
Reference in New Issue
Block a user