mirror of
https://github.com/azalea-rs/simdnbt.git
synced 2025-08-02 15:36:03 +00:00
rename OptionalNbt to Nbt and Nbt to BaseNbt
This commit is contained in:
parent
872ac20e5d
commit
fe2136ce11
8 changed files with 65 additions and 77 deletions
|
@ -35,7 +35,7 @@ pub fn bench_read_file(filename: &str, c: &mut Criterion) {
|
|||
// })
|
||||
// });
|
||||
|
||||
let nbt = simdnbt::borrow::OptionalNbt::read(&mut Cursor::new(input))
|
||||
let nbt = simdnbt::borrow::Nbt::read(&mut Cursor::new(input))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
group.bench_function("simdnbt_borrow_write", |b| {
|
||||
|
@ -56,7 +56,7 @@ pub fn bench_read_file(filename: &str, c: &mut Criterion) {
|
|||
// black_box(nbt);
|
||||
// })
|
||||
// });
|
||||
let nbt = simdnbt::owned::OptionalNbt::read(&mut Cursor::new(input))
|
||||
let nbt = simdnbt::owned::Nbt::read(&mut Cursor::new(input))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
group.bench_function("simdnbt_owned_write", |b| {
|
||||
|
|
|
@ -33,7 +33,7 @@ pub fn bench_read_file(filename: &str, c: &mut Criterion) {
|
|||
graphite_items_from_nbt(graphite_binary::nbt::decode::read(&mut &input[..]).unwrap())
|
||||
.unwrap();
|
||||
let simdnbt_nbt = simdnbt_items_from_nbt(
|
||||
simdnbt::borrow::OptionalNbt::read(&mut Cursor::new(input))
|
||||
simdnbt::borrow::Nbt::read(&mut Cursor::new(input))
|
||||
.unwrap()
|
||||
.unwrap(),
|
||||
)
|
||||
|
@ -63,7 +63,7 @@ pub fn bench_read_file(filename: &str, c: &mut Criterion) {
|
|||
group.bench_function("simdnbt_parse", |b| {
|
||||
b.iter(|| {
|
||||
let input = black_box(input);
|
||||
let nbt = black_box(simdnbt::borrow::OptionalNbt::read(&mut Cursor::new(input)));
|
||||
let nbt = black_box(simdnbt::borrow::Nbt::read(&mut Cursor::new(input)));
|
||||
let nbt = nbt.unwrap().unwrap();
|
||||
black_box(simdnbt_items_from_nbt(nbt));
|
||||
})
|
||||
|
@ -97,7 +97,7 @@ pub struct ItemDisplay {
|
|||
pub color: Option<i32>,
|
||||
}
|
||||
|
||||
fn simdnbt_items_from_nbt(nbt: simdnbt::borrow::Nbt) -> Option<Vec<Option<Item>>> {
|
||||
fn simdnbt_items_from_nbt(nbt: simdnbt::borrow::BaseNbt) -> Option<Vec<Option<Item>>> {
|
||||
let mut items = Vec::new();
|
||||
for item_nbt in nbt
|
||||
.list("i")
|
||||
|
|
|
@ -27,12 +27,12 @@ fn bench_file(filename: &str, c: &mut Criterion) {
|
|||
|
||||
group.bench_function("Decode", |b| {
|
||||
b.iter(|| {
|
||||
black_box(simdnbt::borrow::OptionalNbt::read(&mut decoded_src_stream).unwrap());
|
||||
black_box(simdnbt::borrow::Nbt::read(&mut decoded_src_stream).unwrap());
|
||||
decoded_src_stream.set_position(0);
|
||||
})
|
||||
});
|
||||
|
||||
let nbt = simdnbt::borrow::OptionalNbt::read(&mut decoded_src_stream)
|
||||
let nbt = simdnbt::borrow::Nbt::read(&mut decoded_src_stream)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
group.bench_function("Get", |b| {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::{collections::HashMap, hint::black_box, io::Cursor};
|
||||
|
||||
use simdnbt::borrow::{Nbt, OptionalNbt};
|
||||
use simdnbt::borrow::{BaseNbt, Nbt};
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Item {
|
||||
|
@ -29,7 +29,7 @@ pub struct ItemDisplay {
|
|||
pub color: Option<i32>,
|
||||
}
|
||||
|
||||
fn simdnbt_items_from_nbt(nbt: Nbt) -> Option<Vec<Option<Item>>> {
|
||||
fn simdnbt_items_from_nbt(nbt: BaseNbt) -> Option<Vec<Option<Item>>> {
|
||||
let mut items = Vec::new();
|
||||
for item_nbt in nbt
|
||||
.list("i")
|
||||
|
@ -103,7 +103,7 @@ fn main() {
|
|||
let input = black_box(include_bytes!("../tests/realworld.nbt"));
|
||||
|
||||
for _ in 0..10000 {
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(input));
|
||||
let nbt = Nbt::read(&mut Cursor::new(input));
|
||||
let nbt = black_box(nbt.unwrap().unwrap());
|
||||
black_box(simdnbt_items_from_nbt(nbt));
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ fn main() {
|
|||
}
|
||||
let input = input.as_slice();
|
||||
|
||||
let nbt = simdnbt::owned::OptionalNbt::read(&mut Cursor::new(input))
|
||||
let nbt = simdnbt::owned::Nbt::read(&mut Cursor::new(input))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -21,23 +21,23 @@ pub use self::{compound::CompoundTag, list::ListTag};
|
|||
|
||||
/// A complete NBT container. This contains a name and a compound tag.
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct Nbt<'a> {
|
||||
pub struct BaseNbt<'a> {
|
||||
name: &'a Mutf8Str,
|
||||
tag: CompoundTag<'a>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum OptionalNbt<'a> {
|
||||
Some(Nbt<'a>),
|
||||
pub enum Nbt<'a> {
|
||||
Some(BaseNbt<'a>),
|
||||
None,
|
||||
}
|
||||
|
||||
impl<'a> OptionalNbt<'a> {
|
||||
impl<'a> Nbt<'a> {
|
||||
/// Reads NBT from the given data. Returns `Ok(None)` if there is no data.
|
||||
pub fn read(data: &mut Cursor<&'a [u8]>) -> Result<OptionalNbt<'a>, Error> {
|
||||
pub fn read(data: &mut Cursor<&'a [u8]>) -> Result<Nbt<'a>, Error> {
|
||||
let root_type = data.read_u8().map_err(|_| Error::UnexpectedEof)?;
|
||||
if root_type == END_ID {
|
||||
return Ok(OptionalNbt::None);
|
||||
return Ok(Nbt::None);
|
||||
}
|
||||
if root_type != COMPOUND_ID {
|
||||
return Err(Error::InvalidRootType(root_type));
|
||||
|
@ -45,29 +45,29 @@ impl<'a> OptionalNbt<'a> {
|
|||
let name = read_string(data)?;
|
||||
let tag = CompoundTag::new(data, 0)?;
|
||||
|
||||
Ok(OptionalNbt::Some(Nbt { name, tag }))
|
||||
Ok(Nbt::Some(BaseNbt { name, tag }))
|
||||
}
|
||||
|
||||
pub fn write(&self, data: &mut Vec<u8>) {
|
||||
match self {
|
||||
OptionalNbt::Some(nbt) => nbt.write(data),
|
||||
OptionalNbt::None => {
|
||||
Nbt::Some(nbt) => nbt.write(data),
|
||||
Nbt::None => {
|
||||
data.push(END_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unwrap(self) -> Nbt<'a> {
|
||||
pub fn unwrap(self) -> BaseNbt<'a> {
|
||||
match self {
|
||||
OptionalNbt::Some(nbt) => nbt,
|
||||
OptionalNbt::None => panic!("called `OptionalNbt::unwrap()` on a `None` value"),
|
||||
Nbt::Some(nbt) => nbt,
|
||||
Nbt::None => panic!("called `OptionalNbt::unwrap()` on a `None` value"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_some(&self) -> bool {
|
||||
match self {
|
||||
OptionalNbt::Some(_) => true,
|
||||
OptionalNbt::None => false,
|
||||
Nbt::Some(_) => true,
|
||||
Nbt::None => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,13 +76,13 @@ impl<'a> OptionalNbt<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Nbt<'a> {
|
||||
impl<'a> BaseNbt<'a> {
|
||||
/// Get the name of the NBT compound. This is often an empty string.
|
||||
pub fn name(&self) -> &'a Mutf8Str {
|
||||
self.name
|
||||
}
|
||||
}
|
||||
impl<'a> Deref for Nbt<'a> {
|
||||
impl<'a> Deref for BaseNbt<'a> {
|
||||
type Target = CompoundTag<'a>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
|
@ -90,7 +90,7 @@ impl<'a> Deref for Nbt<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Nbt<'a> {
|
||||
impl<'a> BaseNbt<'a> {
|
||||
pub fn write(&self, data: &mut Vec<u8>) {
|
||||
data.push(COMPOUND_ID);
|
||||
write_string(data, self.name);
|
||||
|
@ -214,7 +214,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn hello_world() {
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(include_bytes!(
|
||||
let nbt = Nbt::read(&mut Cursor::new(include_bytes!(
|
||||
"../../tests/hello_world.nbt"
|
||||
)))
|
||||
.unwrap()
|
||||
|
@ -234,9 +234,7 @@ mod tests {
|
|||
let mut decoded_src_decoder = GzDecoder::new(&mut src_slice);
|
||||
let mut decoded_src = Vec::new();
|
||||
decoded_src_decoder.read_to_end(&mut decoded_src).unwrap();
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(&decoded_src))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let nbt = Nbt::read(&mut Cursor::new(&decoded_src)).unwrap().unwrap();
|
||||
|
||||
assert_eq!(nbt.int("PersistentId"), Some(1946940766));
|
||||
assert_eq!(nbt.list("Rotation").unwrap().floats().unwrap().len(), 2);
|
||||
|
@ -249,9 +247,7 @@ mod tests {
|
|||
let mut decoded_src_decoder = GzDecoder::new(&mut src_slice);
|
||||
let mut decoded_src = Vec::new();
|
||||
decoded_src_decoder.read_to_end(&mut decoded_src).unwrap();
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(&decoded_src))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let nbt = Nbt::read(&mut Cursor::new(&decoded_src)).unwrap().unwrap();
|
||||
|
||||
assert_eq!(nbt.float("foodExhaustionLevel").unwrap() as u32, 2);
|
||||
assert_eq!(nbt.list("Rotation").unwrap().floats().unwrap().len(), 2);
|
||||
|
@ -264,13 +260,11 @@ mod tests {
|
|||
let mut decoded_src_decoder = GzDecoder::new(&mut src_slice);
|
||||
let mut decoded_src = Vec::new();
|
||||
decoded_src_decoder.read_to_end(&mut decoded_src).unwrap();
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(&decoded_src))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let nbt = Nbt::read(&mut Cursor::new(&decoded_src)).unwrap().unwrap();
|
||||
|
||||
let mut out = Vec::new();
|
||||
nbt.write(&mut out);
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(&out)).unwrap().unwrap();
|
||||
let nbt = Nbt::read(&mut Cursor::new(&out)).unwrap().unwrap();
|
||||
|
||||
assert_eq!(nbt.float("foodExhaustionLevel").unwrap() as u32, 2);
|
||||
assert_eq!(nbt.list("Rotation").unwrap().floats().unwrap().len(), 2);
|
||||
|
@ -278,7 +272,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn inttest_1023() {
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(include_bytes!(
|
||||
let nbt = Nbt::read(&mut Cursor::new(include_bytes!(
|
||||
"../../tests/inttest1023.nbt"
|
||||
)))
|
||||
.unwrap()
|
||||
|
@ -306,7 +300,7 @@ mod tests {
|
|||
}
|
||||
data.write_u8(END_ID).unwrap();
|
||||
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(&data)).unwrap().unwrap();
|
||||
let nbt = Nbt::read(&mut Cursor::new(&data)).unwrap().unwrap();
|
||||
let ints = nbt.list("").unwrap().ints().unwrap();
|
||||
for (i, &item) in ints.iter().enumerate() {
|
||||
assert_eq!(i as i32, item);
|
||||
|
@ -328,7 +322,7 @@ mod tests {
|
|||
}
|
||||
data.write_u8(END_ID).unwrap();
|
||||
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(&data)).unwrap().unwrap();
|
||||
let nbt = Nbt::read(&mut Cursor::new(&data)).unwrap().unwrap();
|
||||
let ints = nbt.list("").unwrap().ints().unwrap();
|
||||
for (i, &item) in ints.iter().enumerate() {
|
||||
assert_eq!(i as i32, item);
|
||||
|
@ -350,7 +344,7 @@ mod tests {
|
|||
}
|
||||
data.write_u8(END_ID).unwrap();
|
||||
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(&data)).unwrap().unwrap();
|
||||
let nbt = Nbt::read(&mut Cursor::new(&data)).unwrap().unwrap();
|
||||
let ints = nbt.list("").unwrap().longs().unwrap();
|
||||
for (i, &item) in ints.iter().enumerate() {
|
||||
assert_eq!(i as i64, item);
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
//! afaik, this is currently the fastest nbt decoder in existence.
|
||||
//!
|
||||
//! ```
|
||||
//! use simdnbt::borrow::{Nbt, OptionalNbt};
|
||||
//! use simdnbt::borrow::Nbt;
|
||||
//! use std::io::Cursor;
|
||||
//!
|
||||
//! let nbt = OptionalNbt::read(&mut Cursor::new(include_bytes!("../tests/hello_world.nbt"))).unwrap().unwrap();
|
||||
//! let nbt = Nbt::read(&mut Cursor::new(include_bytes!("../tests/hello_world.nbt"))).unwrap().unwrap();
|
||||
//! assert_eq!(nbt.name().to_str(), "hello world");
|
||||
//! assert_eq!(nbt.string("name").unwrap().to_str(), "Bananrama");
|
||||
//! ```
|
||||
|
|
|
@ -21,27 +21,27 @@ pub use self::{compound::CompoundTag, list::ListTag};
|
|||
|
||||
/// A complete NBT container. This contains a name and a compound tag.
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct Nbt {
|
||||
pub struct BaseNbt {
|
||||
name: Mutf8String,
|
||||
tag: CompoundTag,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum OptionalNbt {
|
||||
Some(Nbt),
|
||||
pub enum Nbt {
|
||||
Some(BaseNbt),
|
||||
None,
|
||||
}
|
||||
|
||||
impl OptionalNbt {
|
||||
impl Nbt {
|
||||
pub fn new(name: Mutf8String, tag: CompoundTag) -> Self {
|
||||
Self::Some(Nbt { name, tag })
|
||||
Self::Some(BaseNbt { name, tag })
|
||||
}
|
||||
|
||||
/// Reads NBT from the given data. Returns `Ok(None)` if there is no data.
|
||||
pub fn read(data: &mut Cursor<&[u8]>) -> Result<OptionalNbt, Error> {
|
||||
pub fn read(data: &mut Cursor<&[u8]>) -> Result<Nbt, Error> {
|
||||
let root_type = data.read_u8().map_err(|_| Error::UnexpectedEof)?;
|
||||
if root_type == END_ID {
|
||||
return Ok(OptionalNbt::None);
|
||||
return Ok(Nbt::None);
|
||||
}
|
||||
if root_type != COMPOUND_ID {
|
||||
return Err(Error::InvalidRootType(root_type));
|
||||
|
@ -49,29 +49,29 @@ impl OptionalNbt {
|
|||
let name = read_string(data)?.to_owned();
|
||||
let tag = CompoundTag::new(data, 0)?;
|
||||
|
||||
Ok(OptionalNbt::Some(Nbt { name, tag }))
|
||||
Ok(Nbt::Some(BaseNbt { name, tag }))
|
||||
}
|
||||
|
||||
pub fn write(&self, data: &mut Vec<u8>) {
|
||||
match self {
|
||||
OptionalNbt::Some(nbt) => nbt.write(data),
|
||||
OptionalNbt::None => {
|
||||
Nbt::Some(nbt) => nbt.write(data),
|
||||
Nbt::None => {
|
||||
data.push(END_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unwrap(self) -> Nbt {
|
||||
pub fn unwrap(self) -> BaseNbt {
|
||||
match self {
|
||||
OptionalNbt::Some(nbt) => nbt,
|
||||
OptionalNbt::None => panic!("called `OptionalNbt::unwrap()` on a `None` value"),
|
||||
Nbt::Some(nbt) => nbt,
|
||||
Nbt::None => panic!("called `OptionalNbt::unwrap()` on a `None` value"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_some(&self) -> bool {
|
||||
match self {
|
||||
OptionalNbt::Some(_) => true,
|
||||
OptionalNbt::None => false,
|
||||
Nbt::Some(_) => true,
|
||||
Nbt::None => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ impl OptionalNbt {
|
|||
}
|
||||
}
|
||||
|
||||
impl Nbt {
|
||||
impl BaseNbt {
|
||||
pub fn new(name: Mutf8String, tag: CompoundTag) -> Self {
|
||||
Self { name, tag }
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ impl Nbt {
|
|||
self.tag.write(data);
|
||||
}
|
||||
}
|
||||
impl Deref for Nbt {
|
||||
impl Deref for BaseNbt {
|
||||
type Target = CompoundTag;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
|
@ -292,7 +292,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn hello_world() {
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(include_bytes!(
|
||||
let nbt = Nbt::read(&mut Cursor::new(include_bytes!(
|
||||
"../../tests/hello_world.nbt"
|
||||
)))
|
||||
.unwrap()
|
||||
|
@ -312,9 +312,7 @@ mod tests {
|
|||
let mut decoded_src_decoder = GzDecoder::new(&mut src_slice);
|
||||
let mut decoded_src = Vec::new();
|
||||
decoded_src_decoder.read_to_end(&mut decoded_src).unwrap();
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(&decoded_src))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let nbt = Nbt::read(&mut Cursor::new(&decoded_src)).unwrap().unwrap();
|
||||
|
||||
assert_eq!(nbt.int("PersistentId"), Some(1946940766));
|
||||
assert_eq!(nbt.list("Rotation").unwrap().floats().unwrap().len(), 2);
|
||||
|
@ -327,9 +325,7 @@ mod tests {
|
|||
let mut decoded_src_decoder = GzDecoder::new(&mut src_slice);
|
||||
let mut decoded_src = Vec::new();
|
||||
decoded_src_decoder.read_to_end(&mut decoded_src).unwrap();
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(&decoded_src))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let nbt = Nbt::read(&mut Cursor::new(&decoded_src)).unwrap().unwrap();
|
||||
|
||||
assert_eq!(nbt.float("foodExhaustionLevel").unwrap() as u32, 2);
|
||||
assert_eq!(nbt.list("Rotation").unwrap().floats().unwrap().len(), 2);
|
||||
|
@ -342,13 +338,11 @@ mod tests {
|
|||
let mut decoded_src_decoder = GzDecoder::new(&mut src_slice);
|
||||
let mut decoded_src = Vec::new();
|
||||
decoded_src_decoder.read_to_end(&mut decoded_src).unwrap();
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(&decoded_src))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let nbt = Nbt::read(&mut Cursor::new(&decoded_src)).unwrap().unwrap();
|
||||
|
||||
let mut out = Vec::new();
|
||||
nbt.write(&mut out);
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(&out)).unwrap().unwrap();
|
||||
let nbt = Nbt::read(&mut Cursor::new(&out)).unwrap().unwrap();
|
||||
|
||||
assert_eq!(nbt.float("foodExhaustionLevel").unwrap() as u32, 2);
|
||||
assert_eq!(nbt.list("Rotation").unwrap().floats().unwrap().len(), 2);
|
||||
|
@ -356,7 +350,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn inttest_1023() {
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(include_bytes!(
|
||||
let nbt = Nbt::read(&mut Cursor::new(include_bytes!(
|
||||
"../../tests/inttest1023.nbt"
|
||||
)))
|
||||
.unwrap()
|
||||
|
@ -384,7 +378,7 @@ mod tests {
|
|||
}
|
||||
data.write_u8(END_ID).unwrap();
|
||||
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(&data)).unwrap().unwrap();
|
||||
let nbt = Nbt::read(&mut Cursor::new(&data)).unwrap().unwrap();
|
||||
let ints = nbt.list("").unwrap().ints().unwrap();
|
||||
for (i, &item) in ints.iter().enumerate() {
|
||||
assert_eq!(i as i32, item);
|
||||
|
@ -406,7 +400,7 @@ mod tests {
|
|||
}
|
||||
data.write_u8(END_ID).unwrap();
|
||||
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(&data)).unwrap().unwrap();
|
||||
let nbt = Nbt::read(&mut Cursor::new(&data)).unwrap().unwrap();
|
||||
let ints = nbt.list("").unwrap().ints().unwrap();
|
||||
for (i, &item) in ints.iter().enumerate() {
|
||||
assert_eq!(i as i32, item);
|
||||
|
@ -428,7 +422,7 @@ mod tests {
|
|||
}
|
||||
data.write_u8(END_ID).unwrap();
|
||||
|
||||
let nbt = OptionalNbt::read(&mut Cursor::new(&data)).unwrap().unwrap();
|
||||
let nbt = Nbt::read(&mut Cursor::new(&data)).unwrap().unwrap();
|
||||
let ints = nbt.list("").unwrap().longs().unwrap();
|
||||
for (i, &item) in ints.iter().enumerate() {
|
||||
assert_eq!(i as i64, item);
|
||||
|
|
Loading…
Add table
Reference in a new issue