Skip to content

Commit 98cfc76

Browse files
committed
Remove BlackBox type
Depends on: dalek-cryptography#149 At the time this provided an interesting way to use the `subtle` implementation of `black_box`, but now that `core::hint::black_box` is stable someone who wants equivalent functionality can implement it themselves using that.
1 parent 4776266 commit 98cfc76

2 files changed

Lines changed: 0 additions & 25 deletions

File tree

src/lib.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -950,21 +950,3 @@ impl ConstantTimeLess for cmp::Ordering {
950950
(a as u8).ct_lt(&(b as u8))
951951
}
952952
}
953-
954-
/// Wrapper type which implements an optimization barrier for all accesses.
955-
#[derive(Clone, Copy, Debug)]
956-
pub struct BlackBox<T: Copy>(T);
957-
958-
impl<T: Copy> BlackBox<T> {
959-
/// Constructs a new instance of `BlackBox` which will wrap the specified value.
960-
///
961-
/// All access to the inner value will be mediated by a `black_box` optimization barrier.
962-
pub fn new(value: T) -> Self {
963-
Self(value)
964-
}
965-
966-
/// Read the inner value, applying an optimization barrier on access.
967-
pub fn get(self) -> T {
968-
black_box(self.0)
969-
}
970-
}

tests/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,3 @@ fn less_than_ordering() {
487487
1
488488
);
489489
}
490-
491-
#[test]
492-
fn black_box_round_trip() {
493-
let n = 42u64;
494-
let black_box = BlackBox::new(n);
495-
assert_eq!(n, black_box.get());
496-
}

0 commit comments

Comments
 (0)