Skip to content

Commit

Permalink
add copy and clone helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
wilson committed Nov 27, 2024
1 parent 8c9d8d4 commit 9b38866
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "enumeration"
version = "3.1.0"
version = "3.1.1"
edition = "2021"
license = "MIT"
description = "An extension to rust enum"
Expand Down
12 changes: 12 additions & 0 deletions src/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ where
/// Get the reference to the static associated constant value of the variant or the default constant value [Self::DEFAULT_VARIANT_ASSOCIATED_VALUE].
fn value(self) -> &'static Self::AssociatedValueType;

#[inline(always)]
/// Get the associated constant value by copying
fn value_copy(self) -> Self::AssociatedValueType where Self::AssociatedValueType: Copy {
*self.value()
}

#[inline(always)]
/// Get the associated constant value by cloning
fn value_clone(self) -> Self::AssociatedValueType where Self::AssociatedValueType: Clone {
self.value().clone()
}

#[inline(always)]
/// Cast index to the respective enumeration.
///
Expand Down

0 comments on commit 9b38866

Please sign in to comment.