Appease clippy

Please my compiler is so angry ;-;
This commit is contained in:
Emi Tatsuo 2020-11-19 17:58:33 -05:00
parent 07c2d539d0
commit 0bcce9fd6f
Signed by: Emi
GPG Key ID: 68FAB2E2E6DFC98B
7 changed files with 16 additions and 16 deletions

View File

@ -11,7 +11,7 @@ pub enum Body {
impl From<Document> for Body {
fn from(document: Document) -> Self {
Body::from(document.to_string())
Self::from(document.to_string())
}
}

View File

@ -183,7 +183,7 @@ impl Document {
.map(URIReference::into_owned)
.or_else(|_| ".".try_into()).expect("Northstar BUG");
let label = LinkLabel::from_lossy(label);
let link = Link { uri, label: Some(label) };
let link = Link { uri: Box::new(uri), label: Some(label) };
let link = Item::Link(link);
self.add_item(link);
@ -213,7 +213,7 @@ impl Document {
.map(URIReference::into_owned)
.or_else(|_| ".".try_into()).expect("Northstar BUG");
let link = Link {
uri,
uri: Box::new(uri),
label: None,
};
let link = Item::Link(link);
@ -391,6 +391,7 @@ impl fmt::Display for Document {
}
}
#[allow(clippy::enum_variant_names)]
enum Item {
Text(Text),
Link(Link),
@ -414,7 +415,7 @@ impl Text {
}
struct Link {
uri: URIReference<'static>,
uri: Box<URIReference<'static>>,
label: Option<LinkLabel>,
}
@ -424,7 +425,7 @@ impl LinkLabel {
fn from_lossy(line: impl Cowy<str>) -> Self {
let line = strip_newlines(line);
LinkLabel(line)
Self(line)
}
}

View File

@ -12,7 +12,7 @@ impl Meta {
/// Creates a new "Meta" string.
/// Fails if `meta` contains `\n`.
pub fn new(meta: impl Cowy<str>) -> Result<Self> {
ensure!(!meta.as_ref().contains("\n"), "Meta must not contain newlines");
ensure!(!meta.as_ref().contains('\n'), "Meta must not contain newlines");
ensure!(meta.as_ref().len() <= Self::MAX_LEN, "Meta must not exceed {} bytes", Self::MAX_LEN);
Ok(Self(meta.into()))

View File

@ -39,7 +39,7 @@ impl Request {
})
}
pub fn uri(&self) -> &URIReference {
pub const fn uri(&self) -> &URIReference {
&self.uri
}
@ -60,7 +60,7 @@ impl Request {
self.certificate = cert;
}
pub fn certificate(&self) -> Option<&Certificate> {
pub const fn certificate(&self) -> Option<&Certificate> {
self.certificate.as_ref()
}
}

View File

@ -12,7 +12,7 @@ pub struct Response {
}
impl Response {
pub fn new(header: ResponseHeader) -> Self {
pub const fn new(header: ResponseHeader) -> Self {
Self {
header,
body: None,
@ -34,7 +34,7 @@ impl Response {
}
pub fn success(mime: &Mime) -> Self {
let header = ResponseHeader::success(&mime);
let header = ResponseHeader::success(mime);
Self::new(header)
}
@ -86,7 +86,7 @@ impl Response {
self
}
pub fn header(&self) -> &ResponseHeader {
pub const fn header(&self) -> &ResponseHeader {
&self.header
}

View File

@ -88,11 +88,11 @@ impl ResponseHeader {
}
}
pub fn status(&self) -> &Status {
pub const fn status(&self) -> &Status {
&self.status
}
pub fn meta(&self) -> &Meta {
pub const fn meta(&self) -> &Meta {
&self.meta
}
}

View File

@ -1,4 +1,3 @@
#[derive(Debug,Copy,Clone,PartialEq,Eq)]
pub struct Status(u8);
@ -22,7 +21,7 @@ impl Status {
pub const CERTIFICATE_NOT_AUTHORIZED: Self = Self(61);
pub const CERTIFICATE_NOT_VALID: Self = Self(62);
pub fn code(&self) -> u8 {
pub const fn code(&self) -> u8 {
self.0
}
@ -30,7 +29,7 @@ impl Status {
self.category().is_success()
}
pub fn category(&self) -> StatusCategory {
pub const fn category(&self) -> StatusCategory {
let class = self.0 / 10;
match class {