mirror of
https://github.com/openharmony/third_party_rust_http.git
synced 2026-07-19 22:53:59 -04:00
Move convert::Into impls to where all the other trait impls are
This commit is contained in:
committed by
Alex Crichton
parent
befc3c0b09
commit
8fe256da0e
+28
-26
@@ -1,7 +1,7 @@
|
||||
use byte_str::ByteStr;
|
||||
use bytes::{Bytes, BytesMut};
|
||||
|
||||
use std::{convert, fmt, mem};
|
||||
use std::{fmt, mem};
|
||||
use std::borrow::Borrow;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::str::FromStr;
|
||||
@@ -32,13 +32,6 @@ pub struct HeaderName {
|
||||
inner: Repr<Custom>,
|
||||
}
|
||||
|
||||
impl convert::Into<Bytes> for HeaderName {
|
||||
#[inline]
|
||||
fn into(self) -> Bytes {
|
||||
self.inner.into()
|
||||
}
|
||||
}
|
||||
|
||||
/// Almost a full `HeaderName`
|
||||
#[derive(Debug, Hash)]
|
||||
pub struct HdrName<'a> {
|
||||
@@ -51,28 +44,10 @@ enum Repr<T> {
|
||||
Custom(T),
|
||||
}
|
||||
|
||||
impl<T> convert::Into<Bytes> for Repr<T>
|
||||
where T: convert::Into<Bytes> {
|
||||
fn into(self) -> Bytes {
|
||||
match self {
|
||||
Repr::Standard(header) =>
|
||||
Bytes::from_static(header.as_str().as_bytes()),
|
||||
Repr::Custom(header) => header.into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Used to hijack the Hash impl
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
struct Custom(ByteStr);
|
||||
|
||||
impl convert::Into<Bytes> for Custom {
|
||||
#[inline]
|
||||
fn into(self) -> Bytes {
|
||||
self.0.into()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct MaybeLower<'a> {
|
||||
buf: &'a [u8],
|
||||
@@ -1538,6 +1513,33 @@ impl<'a> From<&'a HeaderName> for HeaderName {
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl<T> Into<Bytes> for Repr<T>
|
||||
where T: Into<Bytes> {
|
||||
fn into(self) -> Bytes {
|
||||
match self {
|
||||
Repr::Standard(header) =>
|
||||
Bytes::from_static(header.as_str().as_bytes()),
|
||||
Repr::Custom(header) => header.into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<Bytes> for Custom {
|
||||
#[inline]
|
||||
fn into(self) -> Bytes {
|
||||
self.0.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<Bytes> for HeaderName {
|
||||
#[inline]
|
||||
fn into(self) -> Bytes {
|
||||
self.inner.into()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[doc(hidden)]
|
||||
impl From<StandardHeader> for HeaderName {
|
||||
fn from(src: StandardHeader) -> HeaderName {
|
||||
|
||||
Reference in New Issue
Block a user