[−][src]Trait sbitty::SetBit
performing _ | (1 << idx) with n the index
Examples
set bit for big int
Don't pay attention to my bigint implementation.
pub struct BigInt { hwb: i64, lwb: i64, } impl SetBit for BigInt { fn set_bit(&self, idx: usize) -> Result<Self,IndexError> where Self: Sized { if idx >= 128 { Err(IndexError) } else if idx >= 64 { Ok(BigInt{ hwb: self.hwb | (1 << (idx - 64)), lwb: self.lwb }) } else { Ok(BigInt{ hwb: self.hwb, lwb: self.lwb | (1 << (idx - 64)) }) } } }
Required methods
pub fn set_bit(&self, idx: usize) -> Result<Self, IndexError> where
Self: Sized,
[src]
Self: Sized,
Implementors
impl SetBit for i8
[src]
pub fn set_bit(&self, idx: usize) -> Result<Self, IndexError> where
Self: Sized,
[src]
Self: Sized,
impl SetBit for i16
[src]
pub fn set_bit(&self, idx: usize) -> Result<Self, IndexError> where
Self: Sized,
[src]
Self: Sized,
impl SetBit for i32
[src]
pub fn set_bit(&self, idx: usize) -> Result<Self, IndexError> where
Self: Sized,
[src]
Self: Sized,
impl SetBit for i64
[src]
pub fn set_bit(&self, idx: usize) -> Result<Self, IndexError> where
Self: Sized,
[src]
Self: Sized,
impl SetBit for isize
[src]
pub fn set_bit(&self, idx: usize) -> Result<Self, IndexError> where
Self: Sized,
[src]
Self: Sized,
impl SetBit for u8
[src]
pub fn set_bit(&self, idx: usize) -> Result<Self, IndexError> where
Self: Sized,
[src]
Self: Sized,
impl SetBit for u16
[src]
pub fn set_bit(&self, idx: usize) -> Result<Self, IndexError> where
Self: Sized,
[src]
Self: Sized,
impl SetBit for u32
[src]
pub fn set_bit(&self, idx: usize) -> Result<Self, IndexError> where
Self: Sized,
[src]
Self: Sized,
impl SetBit for u64
[src]
pub fn set_bit(&self, idx: usize) -> Result<Self, IndexError> where
Self: Sized,
[src]
Self: Sized,
impl SetBit for usize
[src]
pub fn set_bit(&self, idx: usize) -> Result<Self, IndexError> where
Self: Sized,
[src]
Self: Sized,