mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
Change some generics to impl Trait
This commit is contained in:
parent
44db8948d6
commit
db2fcecdc3
1 changed files with 5 additions and 20 deletions
|
@ -7,10 +7,7 @@ use std::io::BufRead;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_string<R>(stream: &mut R) -> Result<String, Error>
|
fn read_string(stream: &mut impl Read) -> Result<String, Error> {
|
||||||
where
|
|
||||||
R: Read,
|
|
||||||
{
|
|
||||||
let length = stream.read_u16::<BE>()?;
|
let length = stream.read_u16::<BE>()?;
|
||||||
|
|
||||||
let mut buf = Vec::with_capacity(length as usize);
|
let mut buf = Vec::with_capacity(length as usize);
|
||||||
|
@ -22,10 +19,7 @@ where
|
||||||
|
|
||||||
impl Tag {
|
impl Tag {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_known<R>(stream: &mut R, id: u8) -> Result<Tag, Error>
|
fn read_known(stream: &mut impl Read, id: u8) -> Result<Tag, Error> {
|
||||||
where
|
|
||||||
R: Read,
|
|
||||||
{
|
|
||||||
let tag = match id {
|
let tag = match id {
|
||||||
// Signifies the end of a TAG_Compound. It is only ever used inside
|
// Signifies the end of a TAG_Compound. It is only ever used inside
|
||||||
// a TAG_Compound, and is not named despite being in a TAG_Compound
|
// a TAG_Compound, and is not named despite being in a TAG_Compound
|
||||||
|
@ -116,10 +110,7 @@ impl Tag {
|
||||||
Ok(tag)
|
Ok(tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read<R>(stream: &mut R) -> Result<Tag, Error>
|
pub fn read(stream: &mut impl Read) -> Result<Tag, Error> {
|
||||||
where
|
|
||||||
R: Read,
|
|
||||||
{
|
|
||||||
// default to compound tag
|
// default to compound tag
|
||||||
|
|
||||||
// the parent compound only ever has one item
|
// the parent compound only ever has one item
|
||||||
|
@ -135,18 +126,12 @@ impl Tag {
|
||||||
Ok(Tag::Compound(map))
|
Ok(Tag::Compound(map))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_zlib<R>(stream: &mut R) -> Result<Tag, Error>
|
pub fn read_zlib(stream: &mut impl BufRead) -> Result<Tag, Error> {
|
||||||
where
|
|
||||||
R: BufRead,
|
|
||||||
{
|
|
||||||
let mut gz = ZlibDecoder::new(stream);
|
let mut gz = ZlibDecoder::new(stream);
|
||||||
Tag::read(&mut gz)
|
Tag::read(&mut gz)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_gzip<R>(stream: &mut R) -> Result<Tag, Error>
|
pub fn read_gzip(stream: &mut impl Read) -> Result<Tag, Error> {
|
||||||
where
|
|
||||||
R: Read,
|
|
||||||
{
|
|
||||||
let mut gz = GzDecoder::new(stream);
|
let mut gz = GzDecoder::new(stream);
|
||||||
Tag::read(&mut gz)
|
Tag::read(&mut gz)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue