aboutsummaryrefslogtreecommitdiffstats
path: root/crates/yt/src/unreachable.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-07-15 06:56:30 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-07-15 06:56:30 +0200
commite60cf473b3ba1b5c0295d69e93e7d266f62ed60a (patch)
tree360b39d779facf5d0cc63ef71cdc729b922adbc7 /crates/yt/src/unreachable.rs
parentrefactor(crates/yt/download/progress_hook): Use `json_{get,cast}` and owu-colors (diff)
downloadyt-e60cf473b3ba1b5c0295d69e93e7d266f62ed60a.zip
refactor(crates/yt): Allow `missing_panic_docs` and use expect
Diffstat (limited to '')
-rw-r--r--crates/yt/src/unreachable.rs50
1 files changed, 0 insertions, 50 deletions
diff --git a/crates/yt/src/unreachable.rs b/crates/yt/src/unreachable.rs
deleted file mode 100644
index 436fbb6..0000000
--- a/crates/yt/src/unreachable.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-// yt - A fully featured command line YouTube client
-//
-// Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de>
-// Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-// This file is part of Yt.
-//
-// You should have received a copy of the License along with this program.
-// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
-
-// This has been taken from: https://gitlab.torproject.org/tpo/core/arti/-/issues/950
-
-// The functions here should be annotated with `#[inline(always)]`.
-#![allow(clippy::inline_always)]
-
-use std::fmt::Debug;
-
-/// Trait for something that can possibly be unwrapped, like a Result or Option.
-/// It provides semantic information, that unwrapping here should never happen.
-pub trait Unreachable<T> {
- /// Like `expect()`, but does not trigger clippy.
- ///
- /// # Usage
- ///
- /// This method only exists so that we can use it without hitting
- /// `clippy::missing_panics_docs`. Therefore, we should only use it
- /// for situations where we are certain that the panic cannot occur
- /// unless something else is very broken. Consider instead using
- /// `expect()` and adding a `Panics` section to your function
- /// documentation.
- ///
- /// # Panics
- ///
- /// Panics if this is not an object that can be unwrapped, such as
- /// None or an Err.
- fn unreachable(self, msg: &str) -> T;
-}
-impl<T> Unreachable<T> for Option<T> {
- #[inline(always)]
- fn unreachable(self, msg: &str) -> T {
- self.expect(msg)
- }
-}
-impl<T, E: Debug> Unreachable<T> for Result<T, E> {
- #[inline(always)]
- fn unreachable(self, msg: &str) -> T {
- self.expect(msg)
- }
-}