Applied clippy feedback

This commit is contained in:
Trangar 2019-08-08 09:00:50 +02:00 committed by Denis Kolodin
parent 84db98ccde
commit 53136b8fa9
5 changed files with 11 additions and 10 deletions

View File

@ -42,7 +42,7 @@ where
trait Packed {
fn pack(&self) -> Vec<u8>;
fn unpack(data: &Vec<u8>) -> Self;
fn unpack(data: &[u8]) -> Self;
}
impl<T: Transferable> Packed for T {
@ -50,7 +50,7 @@ impl<T: Transferable> Packed for T {
bincode::serialize(&self).expect("can't serialize a transferable object")
}
fn unpack(data: &Vec<u8>) -> Self {
fn unpack(data: &[u8]) -> Self {
bincode::deserialize(&data).expect("can't deserialize a transferable object")
}
}
@ -66,7 +66,7 @@ impl From<usize> for HandlerId {
}
impl HandlerId {
fn raw_id(&self) -> usize {
fn raw_id(self) -> usize {
self.0
}
}
@ -224,7 +224,7 @@ impl Discoverer for Context {
let upd = AgentUpdate::Create(agent_link);
scope.send(upd);
}
let upd = AgentUpdate::Connected(bridge.id.into());
let upd = AgentUpdate::Connected(bridge.id);
bridge.scope.send(upd);
Box::new(bridge)
}

View File

@ -245,8 +245,9 @@ where
.map(|(k, v)| {
(
k.as_str(),
v.to_str()
.expect(format!("Unparsable request header {}: {:?}", k.as_str(), v).as_str()),
v.to_str().unwrap_or_else(|_| {
panic!("Unparsable request header {}: {:?}", k.as_str(), v)
}),
)
})
.collect();

View File

@ -38,6 +38,6 @@ pub trait Task: Drop {
#[doc(hidden)]
fn to_ms(duration: Duration) -> u32 {
let ms = duration.subsec_nanos() / 1_000_000;
let ms = duration.subsec_millis();
ms + duration.as_secs() as u32 * 1000
}

View File

@ -84,7 +84,7 @@ impl WebSocketTask {
IN: Into<Text>,
{
if let Ok(body) = data.into() {
if let Err(_) = self.ws.send_text(&body) {
if self.ws.send_text(&body).is_err() {
self.notification.emit(WebSocketStatus::Error);
}
}
@ -96,7 +96,7 @@ impl WebSocketTask {
IN: Into<Binary>,
{
if let Ok(body) = data.into() {
if let Err(_) = self.ws.send_bytes(&body) {
if self.ws.send_bytes(&body).is_err() {
self.notification.emit(WebSocketStatus::Error);
}
}

View File

@ -82,7 +82,7 @@ impl<COMP: Component> VComp<COMP> {
}
let mut scope = unsafe {
let raw: *mut Scope<CHILD> = ::std::mem::transmute(scope);
let raw: *mut Scope<CHILD> = scope as *mut Scope<CHILD>;
*Box::from_raw(raw)
};