Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit c88b47f

Browse files
authored
refactor: remove const_panic (#14)
1 parent 68194cf commit c88b47f

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

src/principal.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@ use std::convert::TryFrom;
55
use std::fmt::Write;
66
use thiserror::Error;
77

8-
// TODO: remove (blocked by rust-lang/rust#85194)
9-
const ASSERT: [(); 1] = [()];
10-
macro_rules! const_panic {
11-
($($arg:tt)*) => {
12-
#[allow(unconditional_panic)]
13-
let _ = $crate::principal::ASSERT[1];
14-
};
15-
}
16-
178
/// An error happened while encoding, decoding or serializing a principal.
189
#[derive(Error, Clone, Debug, Eq, PartialEq)]
1910
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -181,10 +172,7 @@ impl Principal {
181172
if let Ok(v) = Self::try_from_slice(bytes) {
182173
v
183174
} else {
184-
// TODO: replace with panic (blocked by rust-lang/rust#85194)
185-
const_panic!("slice length exceeded capacity");
186-
//panic!("slice length exceeds capacity")
187-
Self::management_canister()
175+
panic!("slice length exceeds capacity")
188176
}
189177
}
190178

@@ -429,10 +417,7 @@ mod inner {
429417
if let Some(v) = Self::try_from_slice(slice) {
430418
v
431419
} else {
432-
// TODO: replace with panic (blocked by rust-lang/rust#85194)
433-
const_panic!("slice length exceeded capacity");
434-
Self::new()
435-
//panic!("slice length exceeds capacity")
420+
panic!("slice length exceeds capacity")
436421
}
437422
}
438423

0 commit comments

Comments
 (0)