Add typed methods definition.

This commit is contained in:
Stephen Chung
2023-03-22 16:05:25 +08:00
parent 3d4a278f2e
commit e60d0fc0bc
14 changed files with 275 additions and 71 deletions

View File

@@ -38,6 +38,9 @@ struct FnMetadata<'a> {
pub is_anonymous: bool,
#[serde(rename = "type")]
pub typ: FnType,
#[cfg(not(feature = "no_object"))]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub this_type: Option<&'a str>,
pub num_params: usize,
#[serde(default, skip_serializing_if = "StaticVec::is_empty")]
pub params: StaticVec<FnParam<'a>>,
@@ -88,6 +91,8 @@ impl<'a> From<&'a FuncInfo> for FnMetadata<'a> {
#[cfg(not(feature = "no_function"))]
is_anonymous: crate::parser::is_anonymous_fn(&info.metadata.name),
typ,
#[cfg(not(feature = "no_object"))]
this_type: info.metadata.this_type.as_ref().map(|s| s.as_str()),
num_params: info.metadata.num_params,
params: info
.metadata