Skip to content

Commit 549e039

Browse files
committed
fix: better errors for collections
1 parent add4d6a commit 549e039

File tree

7 files changed

+21
-17
lines changed

7 files changed

+21
-17
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ categories = ["encoding"]
1212
license-file = "LICENSE.txt"
1313

1414
[workspace.dependencies]
15-
tlbits = { path = "./crates/bits", version = "0.7.1" }
16-
tlb = { path = "./crates/tlb", version = "0.7.1" }
17-
tlb-ton = { path = "./crates/tlb-ton", version = "0.7.1" }
18-
ton-contracts = { path = "./crates/contracts", version = "0.7.1" }
19-
toner = { path = "./crates/toner", version = "0.7.1" }
15+
tlbits = { path = "./crates/bits", version = "0.7.2" }
16+
tlb = { path = "./crates/tlb", version = "0.7.2" }
17+
tlb-ton = { path = "./crates/tlb-ton", version = "0.7.2" }
18+
ton-contracts = { path = "./crates/contracts", version = "0.7.2" }
19+
toner = { path = "./crates/toner", version = "0.7.2" }
2020

2121
anyhow = "1"
2222
arbitrary = "1.4"

crates/bits/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tlbits"
3-
version = "0.7.1"
3+
version = "0.7.2"
44
edition.workspace = true
55
rust-version.workspace = true
66
repository.workspace = true

crates/bits/src/as/len.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::{
88
use bitvec::{boxed::BitBox, order::Msb0, slice::BitSlice, vec::BitVec, view::AsBits};
99

1010
use crate::{
11+
Context,
1112
r#as::{BorrowCow, Same},
1213
de::{BitReader, BitReaderExt, BitUnpackAs},
1314
ser::{BitPackAs, BitWriter, BitWriterExt},
@@ -39,7 +40,8 @@ impl<As: ?Sized, const BITS: usize> VarLen<As, BITS> {
3940
{
4041
let iter = source.into_iter();
4142
writer
42-
.pack_as::<_, NBits<BITS>>(iter.len(), ())?
43+
.pack_as::<_, NBits<BITS>>(iter.len(), ())
44+
.context("length")?
4345
.pack_many_as::<_, <&'a As as IntoIterator>::Item>(iter, args)?;
4446
Ok(())
4547
}
@@ -56,7 +58,7 @@ impl<As: ?Sized, const BITS: usize> VarLen<As, BITS> {
5658
As::Item: BitUnpackAs<'de, <T as IntoIterator>::Item>,
5759
<As::Item as BitUnpackAs<'de, <T as IntoIterator>::Item>>::Args: Clone,
5860
{
59-
let len: usize = reader.unpack_as::<_, NBits<BITS>>(())?;
61+
let len: usize = reader.unpack_as::<_, NBits<BITS>>(()).context("length")?;
6062
reader
6163
.unpack_iter_as::<_, As::Item>(args)
6264
.take(len)
@@ -77,7 +79,8 @@ impl<const BITS: usize> BitPackAs<BitSlice<u8, Msb0>> for VarLen<Same, BITS> {
7779
W: BitWriter + ?Sized,
7880
{
7981
writer
80-
.pack_as::<_, NBits<BITS>>(source.len(), ())?
82+
.pack_as::<_, NBits<BITS>>(source.len(), ())
83+
.context("length")?
8184
.write_bitslice(source)
8285
}
8386
}
@@ -133,7 +136,7 @@ impl<'de: 'a, 'a, const BITS: usize> BitUnpackAs<'de, Cow<'a, BitSlice<u8, Msb0>
133136
where
134137
R: BitReader<'de> + ?Sized,
135138
{
136-
let len = reader.unpack_as::<_, NBits<BITS>>(())?;
139+
let len = reader.unpack_as::<_, NBits<BITS>>(()).context("length")?;
137140
reader.unpack_as::<_, BorrowCow>(len)
138141
}
139142
}
@@ -175,7 +178,8 @@ impl<const BITS: usize> BitPackAs<[u8]> for VarLen<Same, BITS> {
175178
W: BitWriter + ?Sized,
176179
{
177180
writer
178-
.pack_as::<_, NBits<BITS>>(source.len(), ())?
181+
.pack_as::<_, NBits<BITS>>(source.len(), ())
182+
.context("length")?
179183
.write_bitslice(source.as_bits())
180184
}
181185
}
@@ -201,7 +205,7 @@ impl<'de: 'a, 'a, const BITS: usize> BitUnpackAs<'de, Cow<'a, [u8]>> for VarLen<
201205
where
202206
R: BitReader<'de> + ?Sized,
203207
{
204-
let len: usize = reader.unpack_as::<_, NBits<BITS>>(())?;
208+
let len: usize = reader.unpack_as::<_, NBits<BITS>>(()).context("length")?;
205209
reader.unpack_as::<_, BorrowCow>(len)
206210
}
207211
}
@@ -609,7 +613,7 @@ impl<'de: 'a, 'a, const BITS: usize> BitUnpackAs<'de, Cow<'a, str>> for VarLen<S
609613
where
610614
R: BitReader<'de> + ?Sized,
611615
{
612-
let len: usize = reader.unpack_as::<_, NBits<BITS>>(())?;
616+
let len: usize = reader.unpack_as::<_, NBits<BITS>>(()).context("length")?;
613617
reader.unpack_as::<_, BorrowCow>(len)
614618
}
615619
}

crates/contracts/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ton-contracts"
3-
version = "0.7.1"
3+
version = "0.7.2"
44
edition.workspace = true
55
rust-version.workspace = true
66
repository.workspace = true

crates/tlb-ton/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tlb-ton"
3-
version = "0.7.1"
3+
version = "0.7.2"
44
edition.workspace = true
55
rust-version.workspace = true
66
repository.workspace = true

crates/tlb/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tlb"
3-
version = "0.7.1"
3+
version = "0.7.2"
44
edition.workspace = true
55
rust-version.workspace = true
66
repository.workspace = true

crates/toner/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "toner"
3-
version = "0.7.1"
3+
version = "0.7.2"
44
edition.workspace = true
55
rust-version.workspace = true
66
repository.workspace = true

0 commit comments

Comments
 (0)