Skip to content

Commit c4ebda1

Browse files
Restore sizeof and bump patch version (#157)
Signed-off-by: Dori Medini <[email protected]>
1 parent cbaced5 commit c4ebda1

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

crates/starknet-types-core/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "starknet-types-core"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
edition = "2021"
55
license = "MIT"
66
homepage = "https://github.com/starknet-io/types-rs"
@@ -15,6 +15,7 @@ lambdaworks-math = { version = "0.12.0", default-features = false }
1515
num-traits = { version = "0.2", default-features = false }
1616
num-bigint = { version = "0.4", default-features = false }
1717
num-integer = { version = "0.1", default-features = false }
18+
size-of = { version = "0.1.5", default-features = false }
1819

1920
# Optional
2021
arbitrary = { version = "1.3", optional = true }

crates/starknet-types-core/src/felt/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use num_bigint::{BigInt, BigUint, Sign};
3434
use num_integer::Integer;
3535
use num_traits::{One, Zero};
3636
pub use primitive_conversions::PrimitiveFromFeltError;
37+
use size_of::SizeOf;
3738

3839
use lambdaworks_math::{
3940
field::{
@@ -48,6 +49,10 @@ use lambdaworks_math::{
4849
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
4950
pub struct Felt(pub(crate) FieldElement<Stark252PrimeField>);
5051

52+
impl SizeOf for Felt {
53+
fn size_of_children(&self, _context: &mut size_of::Context) {}
54+
}
55+
5156
#[derive(Debug)]
5257
pub struct FromStrError(CreationError);
5358

@@ -768,6 +773,7 @@ mod test {
768773
use num_traits::Num;
769774
use proptest::prelude::*;
770775
use regex::Regex;
776+
use size_of::TotalSize;
771777

772778
#[test]
773779
fn test_debug_format() {
@@ -1329,4 +1335,15 @@ mod test {
13291335
assert_eq!(one, Felt::ONE);
13301336
assert_eq!(zero, Felt::ZERO);
13311337
}
1338+
1339+
#[test]
1340+
fn felt_size_of() {
1341+
assert_eq!(Felt::ZERO.size_of(), TotalSize::total(32));
1342+
assert_eq!(Felt::ONE.size_of(), TotalSize::total(32));
1343+
assert_eq!(
1344+
Felt(FieldElement::from(1600000000)).size_of(),
1345+
TotalSize::total(32)
1346+
);
1347+
assert_eq!(Felt::MAX.size_of(), TotalSize::total(32));
1348+
}
13321349
}

0 commit comments

Comments
 (0)