From 4f9fe856a25ab29345b90e7725509e9ee38a37be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:41 +0200 Subject: Adding upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/parking_lot_core-0.8.6/src/util.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 vendor/parking_lot_core-0.8.6/src/util.rs (limited to 'vendor/parking_lot_core-0.8.6/src/util.rs') diff --git a/vendor/parking_lot_core-0.8.6/src/util.rs b/vendor/parking_lot_core-0.8.6/src/util.rs new file mode 100644 index 000000000..d7aaa8715 --- /dev/null +++ b/vendor/parking_lot_core-0.8.6/src/util.rs @@ -0,0 +1,31 @@ +// Copyright 2016 Amanieu d'Antras +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +// Option::unchecked_unwrap +pub trait UncheckedOptionExt { + unsafe fn unchecked_unwrap(self) -> T; +} + +impl UncheckedOptionExt for Option { + #[inline] + unsafe fn unchecked_unwrap(self) -> T { + match self { + Some(x) => x, + None => unreachable(), + } + } +} + +// hint::unreachable_unchecked() in release mode +#[inline] +unsafe fn unreachable() -> ! { + if cfg!(debug_assertions) { + unreachable!(); + } else { + core::hint::unreachable_unchecked() + } +} -- cgit v1.2.3