mirror of
https://github.com/azalea-rs/simdnbt.git
synced 2025-08-02 07:26:04 +00:00
add NbtList::as_nbt_tags
This commit is contained in:
parent
922701104a
commit
c255ab673a
2 changed files with 120 additions and 0 deletions
|
@ -304,4 +304,63 @@ impl<'a> NbtList<'a> {
|
|||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_nbt_tags(&self) -> Vec<super::NbtTag> {
|
||||
match self {
|
||||
NbtList::Empty => vec![],
|
||||
NbtList::Byte(bytes) => bytes
|
||||
.iter()
|
||||
.map(|&byte| super::NbtTag::Byte(byte))
|
||||
.collect(),
|
||||
NbtList::Short(shorts) => shorts
|
||||
.to_vec()
|
||||
.into_iter()
|
||||
.map(|short| super::NbtTag::Short(short))
|
||||
.collect(),
|
||||
NbtList::Int(ints) => ints
|
||||
.to_vec()
|
||||
.into_iter()
|
||||
.map(|int| super::NbtTag::Int(int))
|
||||
.collect(),
|
||||
NbtList::Long(longs) => longs
|
||||
.to_vec()
|
||||
.into_iter()
|
||||
.map(|long| super::NbtTag::Long(long))
|
||||
.collect(),
|
||||
NbtList::Float(floats) => floats
|
||||
.to_vec()
|
||||
.into_iter()
|
||||
.map(|float| super::NbtTag::Float(float))
|
||||
.collect(),
|
||||
NbtList::Double(doubles) => doubles
|
||||
.to_vec()
|
||||
.into_iter()
|
||||
.map(|double| super::NbtTag::Double(double))
|
||||
.collect(),
|
||||
NbtList::ByteArray(byte_arrays) => byte_arrays
|
||||
.iter()
|
||||
.map(|&array| super::NbtTag::ByteArray(array))
|
||||
.collect(),
|
||||
NbtList::String(strings) => strings
|
||||
.iter()
|
||||
.map(|&string| super::NbtTag::String(string))
|
||||
.collect(),
|
||||
NbtList::List(lists) => lists
|
||||
.iter()
|
||||
.map(|list| super::NbtTag::List(list.clone()))
|
||||
.collect(),
|
||||
NbtList::Compound(compounds) => compounds
|
||||
.iter()
|
||||
.map(|compound| super::NbtTag::Compound(compound.clone()))
|
||||
.collect(),
|
||||
NbtList::IntArray(int_arrays) => int_arrays
|
||||
.iter()
|
||||
.map(|array| super::NbtTag::IntArray(array.clone()))
|
||||
.collect(),
|
||||
NbtList::LongArray(long_arrays) => long_arrays
|
||||
.iter()
|
||||
.map(|array| super::NbtTag::LongArray(array.clone()))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -350,6 +350,67 @@ impl NbtList {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_nbt_tags(&self) -> Vec<super::NbtTag> {
|
||||
match self {
|
||||
NbtList::Empty => vec![],
|
||||
NbtList::Byte(bytes) => bytes
|
||||
.iter()
|
||||
.map(|&byte| super::NbtTag::Byte(byte))
|
||||
.collect(),
|
||||
NbtList::Short(shorts) => shorts
|
||||
.to_vec()
|
||||
.into_iter()
|
||||
.map(|short| super::NbtTag::Short(short))
|
||||
.collect(),
|
||||
NbtList::Int(ints) => ints
|
||||
.to_vec()
|
||||
.into_iter()
|
||||
.map(|int| super::NbtTag::Int(int))
|
||||
.collect(),
|
||||
NbtList::Long(longs) => longs
|
||||
.to_vec()
|
||||
.into_iter()
|
||||
.map(|long| super::NbtTag::Long(long))
|
||||
.collect(),
|
||||
NbtList::Float(floats) => floats
|
||||
.to_vec()
|
||||
.into_iter()
|
||||
.map(|float| super::NbtTag::Float(float))
|
||||
.collect(),
|
||||
NbtList::Double(doubles) => doubles
|
||||
.to_vec()
|
||||
.into_iter()
|
||||
.map(|double| super::NbtTag::Double(double))
|
||||
.collect(),
|
||||
NbtList::ByteArray(byte_arrays) => byte_arrays
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|array| super::NbtTag::ByteArray(array))
|
||||
.collect(),
|
||||
NbtList::String(strings) => strings
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|string| super::NbtTag::String(string))
|
||||
.collect(),
|
||||
NbtList::List(lists) => lists
|
||||
.iter()
|
||||
.map(|list| super::NbtTag::List(list.clone()))
|
||||
.collect(),
|
||||
NbtList::Compound(compounds) => compounds
|
||||
.iter()
|
||||
.map(|compound| super::NbtTag::Compound(compound.clone()))
|
||||
.collect(),
|
||||
NbtList::IntArray(int_arrays) => int_arrays
|
||||
.iter()
|
||||
.map(|array| super::NbtTag::IntArray(array.clone()))
|
||||
.collect(),
|
||||
NbtList::LongArray(long_arrays) => long_arrays
|
||||
.iter()
|
||||
.map(|array| super::NbtTag::LongArray(array.clone()))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<i8>> for NbtList {
|
||||
|
|
Loading…
Add table
Reference in a new issue