mirror of
https://github.com/nushell/nushell
synced 2025-01-16 07:04:09 +00:00
2956b0b087
* Add some more docs * More docs * More docs
18 lines
489 B
Rust
18 lines
489 B
Rust
#![allow(clippy::should_implement_trait)]
|
|
|
|
/// Helper type to allow passing something that may potentially be owned, but could also be borrowed
|
|
#[derive(Debug)]
|
|
pub enum MaybeOwned<'a, T> {
|
|
Owned(T),
|
|
Borrowed(&'a T),
|
|
}
|
|
|
|
impl<T> MaybeOwned<'_, T> {
|
|
/// Allows the borrowing of an owned value or passes out the borrowed value
|
|
pub fn borrow(&self) -> &T {
|
|
match self {
|
|
MaybeOwned::Owned(v) => v,
|
|
MaybeOwned::Borrowed(v) => v,
|
|
}
|
|
}
|
|
}
|