Skip to content

Commit

Permalink
feat: Remove {u256, u512}_from_slice
Browse files Browse the repository at this point in the history
I don't think we need these methods any more. A caller with an
arbitrarily-sized slice can use Value::power_of_two. A caller with a
precisely-sized slice can use the safer Value::{u256, u512}.

We can remove this commit from the PR if it turns out that we need
{u256, u512}_from_slice for some reason.
  • Loading branch information
uncomputable committed Jul 26, 2024
1 parent c1527fa commit f308d5e
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::dag::{Dag, DagLike, NoSharing};
use crate::types::Final;

use std::collections::VecDeque;
use std::convert::TryInto;
use std::fmt;
use std::hash::Hash;
use std::sync::Arc;
Expand Down Expand Up @@ -189,27 +188,6 @@ impl Value {
Value::power_of_two(bytes)
}

/// Create a value from a byte slice.
/// Create a value from a slice containing 32 bytes.
///
/// ## Panics
///
/// The slice doesn't have exactly 32 bytes.
pub fn u256_from_slice(bytes: &[u8]) -> Arc<Self> {
let bytes: &[u8; 32] = bytes.try_into().expect("Expect 32-byte slice");
Value::u256(bytes)
}

/// Create a value from a slice containing 64 bytes.
///
/// ## Panics
///
/// The slice doesn't have exactly 64 bytes.
pub fn u512_from_slice(bytes: &[u8]) -> Arc<Self> {
let bytes: &[u8; 64] = bytes.try_into().expect("Expect 64-byte slice");
Value::u512(bytes)
}

/// Create a value from a byte slice.
///
/// ## Panics
Expand Down

0 comments on commit f308d5e

Please sign in to comment.