Struct std::b512::B512

pub struct B512 {
    /// The two `b256`s that make up the `B512`.
    bits: [b256; 2],
}
Expand description

Stores two b256s in contiguous memory.
Guaranteed to be contiguous for use with ec-recover: std::ecr::ec_recover.

Fields

bits: [b256; 2]

The two b256s that make up the B512.

Implementations

fn new() -> Self

Initializes a new, zeroed B512.

Returns

  • [B512] - A zero value B512.

Examples

use std::b512::B512;

fn foo() {
    let zero = B512::new();
}

fn bits(self) -> [b256; 2]

Returns the underlying bits for the B512 type.

Returns

  • [[b256; 2]] - The two b256s that make up the B512.

Examples

use std::{b512::B512, constants::ZERO_B256);

fn foo() {
    let zero = B512::new();
    assert(zero.bits() == [ZERO_B256, ZERO_B256]);
}

Trait Implementations

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

Additional Information

This function is inherited when eq() is implemented.

Arguments

  • other: [Self] - The value of the same type.

Returns

  • [bool] - true if the two values are not equal, otherwise false.

Examples

struct MyStruct {
    val: u64,
}

impl Eq for MyStruct {
    fn eq(self, other: Self) -> bool {
         self.val == other.val
    }
}

fn foo() {
    let struct1 = MyStruct { val: 10 };
    let struct2 = MyStruct { val: 2 };
    let result = struct1 != struct2;
    assert(result);
}

fn from(components: (b256, b256)) -> Self