1use crate::alloc;
2#[cfg(feature = "doc")]
3use crate::alloc::prelude::*;
4use crate::function_meta::{AssociatedName, ToFieldFunction, ToInstance};
5use crate::hash::Hash;
6use crate::runtime::Protocol;
7
8#[doc(inline)]
9pub use rune_core::params::Params;
10
11impl<T, const N: usize> ToInstance for Params<T, N>
12where
13 T: ToInstance,
14{
15 #[inline]
16 fn to_instance(self) -> alloc::Result<AssociatedName> {
17 let info = self.name.to_instance()?;
18
19 Ok(AssociatedName {
20 kind: info.kind,
21 function_parameters: Hash::parameters(self.parameters),
22 #[cfg(feature = "doc")]
23 parameter_types: self.parameters.iter().copied().try_collect()?,
24 })
25 }
26}
27
28impl<T, const N: usize> ToFieldFunction for Params<T, N>
29where
30 T: ToFieldFunction,
31{
32 #[inline]
33 fn to_field_function(self, protocol: &'static Protocol) -> alloc::Result<AssociatedName> {
34 let info = self.name.to_field_function(protocol)?;
35
36 Ok(AssociatedName {
37 kind: info.kind,
38 function_parameters: Hash::parameters(self.parameters),
39 #[cfg(feature = "doc")]
40 parameter_types: self.parameters.iter().copied().try_collect()?,
41 })
42 }
43}