Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic if map's item length is not static #137

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

jan-ferdinand
Copy link
Member

No description provided.

Comment on lines +53 to +70
/// See [`BFieldCodec::static_length`].
pub(crate) fn static_length(&self) -> Option<usize> {
match self {
DataType::Bool => bool::static_length(),
DataType::U32 => u32::static_length(),
DataType::U64 => u64::static_length(),
DataType::U128 => u128::static_length(),
DataType::Bfe => BFieldElement::static_length(),
DataType::Xfe => XFieldElement::static_length(),
DataType::Digest => Digest::static_length(),
DataType::List(_) => None,
DataType::Array(a) => Some(a.length * a.element_type.static_length()?),
DataType::Tuple(t) => t.iter().map(|dt| dt.static_length()).sum(),
DataType::VoidPointer => None,
DataType::StructRef(s) => s.fields.iter().map(|(_, dt)| dt.static_length()).sum(),
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this method doesn't already exists! But if it doesn't (I couldn't find it) we should definitely have it!

@Sword-Smith
Copy link
Contributor

Good tests!

@jan-ferdinand jan-ferdinand force-pushed the chain_map_fail_with_dyn_size_types branch from afbeca2 to 54b647e Compare September 25, 2024 09:54
@jan-ferdinand jan-ferdinand merged commit 54b647e into master Sep 25, 2024
3 checks passed
@jan-ferdinand jan-ferdinand deleted the chain_map_fail_with_dyn_size_types branch September 25, 2024 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants