pub struct Method {
pub name: String,
pub signature: String,
pub parsed_signature: FunctionSignature,
pub body_source: Option<String>,
pub is_unsafe: bool,
pub is_const: bool,
pub is_async: bool,
pub docs: Option<String>,
/* private fields */
}Expand description
A method (from an impl block).
Provides method metadata including signature, source code, and the ability to navigate to parameter and return types.
§Example
ⓘ
let user = krate.get_struct("User")?;
for method in user.methods()? {
println!("Method: {}", method.name);
println!(" Signature: {}", method.signature);
// Get return type
if let Some(return_type) = method.return_type_def()? {
println!(" Returns: {}", return_type.name());
}
// Get method body source
if let Some(body) = &method.body_source {
println!(" Body: {}", body);
}
}Fields§
§name: StringMethod name
signature: StringFull signature as a string
parsed_signature: FunctionSignatureParsed signature components
body_source: Option<String>Method body source code (if available)
is_unsafe: boolWhether this is an unsafe method
is_const: boolWhether this is a const method
is_async: boolWhether this is an async method
docs: Option<String>Doc comments
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Method
impl RefUnwindSafe for Method
impl Send for Method
impl Sync for Method
impl Unpin for Method
impl UnwindSafe for Method
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more