Remove unnecessary prefixes (#10158)

This commit is contained in:
Charlie Marsh 2024-12-25 14:18:01 -05:00 committed by GitHub
parent 3cb723220e
commit bec8468183
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 124 additions and 175 deletions

View file

@ -45,7 +45,7 @@ pub trait Cacheable: Sized {
/// Deserialize a value from bytes aligned to a 16-byte boundary.
fn from_aligned_bytes(bytes: AlignedVec) -> Result<Self::Target, Error>;
/// Serialize bytes to a possibly owned byte buffer.
fn to_bytes(&self) -> Result<Cow<'_, [u8]>, crate::Error>;
fn to_bytes(&self) -> Result<Cow<'_, [u8]>, Error>;
/// Convert this type into its final form.
fn into_target(self) -> Self::Target;
}
@ -814,7 +814,7 @@ impl DataWithCachePolicy {
/// If the given byte buffer is not in a valid format or if the reader
/// fails, then this returns an error.
pub fn from_reader(mut rdr: impl std::io::Read) -> Result<Self, Error> {
let mut aligned_bytes = rkyv::util::AlignedVec::new();
let mut aligned_bytes = AlignedVec::new();
aligned_bytes
.extend_from_reader(&mut rdr)
.map_err(ErrorKind::Io)?;

View file

@ -182,10 +182,7 @@ impl<'b, B: 'b + ?Sized + AsRef<[u8]>, I: Iterator<Item = &'b B>> CacheControlPa
/// given iterator should yield elements that satisfy `AsRef<[u8]>`.
fn new<II: IntoIterator<IntoIter = I>>(headers: II) -> CacheControlParser<'b, I> {
let mut directives = headers.into_iter();
let cur = directives
.next()
.map(std::convert::AsRef::as_ref)
.unwrap_or(b"");
let cur = directives.next().map(AsRef::as_ref).unwrap_or(b"");
CacheControlParser {
cur,
directives,
@ -265,7 +262,7 @@ impl<'b, B: 'b + ?Sized + AsRef<[u8]>, I: Iterator<Item = &'b B>> CacheControlPa
self.cur = &self.cur[1..];
self.parse_quoted_string()
} else {
self.parse_token().map(std::string::String::into_bytes)
self.parse_token().map(String::into_bytes)
}
}
@ -371,7 +368,7 @@ impl<'b, B: 'b + ?Sized + AsRef<[u8]>, I: Iterator<Item = &'b B>> Iterator
fn next(&mut self) -> Option<CacheControlDirective> {
loop {
if self.cur.is_empty() {
self.cur = self.directives.next().map(std::convert::AsRef::as_ref)?;
self.cur = self.directives.next().map(AsRef::as_ref)?;
}
while !self.cur.is_empty() {
self.skip_whitespace();

View file

@ -1039,7 +1039,7 @@ mod tests {
.iter()
.map(|file| uv_pypi_types::base_url_join_relative(base.as_url().as_str(), &file.url))
.collect::<Result<Vec<_>, JoinRelativeError>>()?;
let urls = urls.iter().map(reqwest::Url::as_str).collect::<Vec<_>>();
let urls = urls.iter().map(Url::as_str).collect::<Vec<_>>();
insta::assert_debug_snapshot!(urls, @r###"
[
"https://account.d.codeartifact.us-west-2.amazonaws.com/pypi/shared-packages-pypi/simple/0.1/Flask-0.1.tar.gz#sha256=9da884457e910bf0847d396cb4b778ad9f3c3d17db1c5997cb861937bd284237",

View file

@ -77,11 +77,11 @@ where
///
/// If the bytes fail validation (e.g., contains unaligned pointers or
/// strings aren't valid UTF-8), then this returns an error.
pub fn new(raw: rkyv::util::AlignedVec) -> Result<Self, Error> {
pub fn new(raw: AlignedVec) -> Result<Self, Error> {
// We convert the error to a simple string because... the error type
// does not implement Send. And I don't think we really need to keep
// the error type around anyway.
let _ = rkyv::access::<A::Archived, rkyv::rancor::Error>(&raw)
let _ = rkyv::access::<A::Archived, rancor::Error>(&raw)
.map_err(|e| ErrorKind::ArchiveRead(e.to_string()))?;
Ok(Self {
raw,
@ -98,7 +98,7 @@ where
/// If the bytes fail validation (e.g., contains unaligned pointers or
/// strings aren't valid UTF-8), then this returns an error.
pub fn from_reader<R: std::io::Read>(mut rdr: R) -> Result<Self, Error> {
let mut buf = rkyv::util::AlignedVec::with_capacity(1024);
let mut buf = AlignedVec::with_capacity(1024);
buf.extend_from_reader(&mut rdr).map_err(ErrorKind::Io)?;
Self::new(buf)
}