rune_core/
params.rs

1use crate::hash::{Hash, IntoHash};
2
3/// Helper to register a parameterized function.
4///
5/// This is used to wrap the name of the function in order to associated
6/// parameters with it.
7#[derive(Clone)]
8#[non_exhaustive]
9pub struct Params<T, const N: usize> {
10    #[doc(hidden)]
11    pub name: T,
12    #[doc(hidden)]
13    pub parameters: [Hash; N],
14}
15
16impl<T, const N: usize> Params<T, N> {
17    /// Construct a new parameters wrapper.
18    pub const fn new(name: T, parameters: [Hash; N]) -> Self {
19        Self { name, parameters }
20    }
21}
22
23impl<T, const N: usize> IntoHash for Params<T, N>
24where
25    T: IntoHash,
26{
27    #[inline]
28    fn into_hash(self) -> Hash {
29        self.name.into_hash()
30    }
31}