panic if queue is too big
This commit is contained in:
parent
e15637f0dd
commit
588d673ad0
|
@ -12,6 +12,10 @@ pub struct Queue<'a, T: Copy> {
|
|||
impl<'a, T: Copy> Queue<'a, T> {
|
||||
/// Constructs a new queue.
|
||||
pub const fn new(mut hold: Option<T>, mut next: &'a [T]) -> Self {
|
||||
if next.len() + 1 > u16::MAX as usize {
|
||||
panic!("too many elements in queue");
|
||||
}
|
||||
|
||||
// SIGH. so `hold.is_none()` is not valid in `const fn`, for some obscure reason.
|
||||
#[allow(clippy::redundant_pattern_matching)]
|
||||
if let None = hold {
|
||||
|
|
Loading…
Reference in New Issue