Skip to content

Commit

Permalink
fix tryfrom
Browse files Browse the repository at this point in the history
  • Loading branch information
sergerad committed Jul 26, 2024
1 parent d2c3b18 commit b53d931
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions air/src/trace/rows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ use vm_core::Felt;

/// Represents the types of errors that can occur when converting from and into [`RowIndex`] and
/// using its operations.
///
/// Currently only used during panic.
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
enum RowIndexError<T> {
pub enum RowIndexError<T> {
#[error("value is too large to be converted into RowIndex: {0}")]
InvalidSize(T),
}
Expand Down Expand Up @@ -78,10 +76,10 @@ impl From<usize> for RowIndex {
/// This function will panic if the number represented by the u64 is greater than the maximum
/// [`RowIndex`] value, `u32::MAX`.
impl TryFrom<u64> for RowIndex {
type Error = &'static str;
type Error = RowIndexError<u64>;

fn try_from(value: u64) -> Result<Self, Self::Error> {
let value = u32::try_from(value).map_err(|_| RowIndexError::InvalidSize(value)).unwrap();
let value = u32::try_from(value).map_err(|_| RowIndexError::InvalidSize(value))?;
Ok(RowIndex::from(value))
}
}
Expand Down

0 comments on commit b53d931

Please sign in to comment.