pub struct MethodInfo { /* private fields */ }Expand description
Metadata for a single method, used to build the LCOM4 method graph.
Each method carries its name, the set of fields it accesses, and the set of other methods on the same type that it calls directly. Field names and method names are plain strings extracted by the caller from HIR or other analysis passes.
§Examples
use std::collections::BTreeSet;
use whitaker_common::lcom4::MethodInfo;
let method = MethodInfo::new(
"process",
BTreeSet::from(["data".into(), "buffer".into()]),
BTreeSet::new(),
);
assert_eq!(method.name(), "process");
assert!(method.accessed_fields().contains("data"));
assert!(method.called_methods().is_empty());Implementations§
Source§impl MethodInfo
impl MethodInfo
Sourcepub fn new(
name: impl Into<String>,
accessed_fields: BTreeSet<String>,
called_methods: BTreeSet<String>,
) -> Self
pub fn new( name: impl Into<String>, accessed_fields: BTreeSet<String>, called_methods: BTreeSet<String>, ) -> Self
Creates a new MethodInfo with the given name, accessed fields, and
called methods.
§Examples
use std::collections::BTreeSet;
use whitaker_common::lcom4::MethodInfo;
let m = MethodInfo::new(
"process",
BTreeSet::from(["data".into()]),
BTreeSet::from(["validate".into()]),
);
assert_eq!(m.name(), "process");Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns the method name.
§Examples
use std::collections::BTreeSet;
use whitaker_common::lcom4::MethodInfo;
let m = MethodInfo::new("read", BTreeSet::new(), BTreeSet::new());
assert_eq!(m.name(), "read");Sourcepub fn accessed_fields(&self) -> &BTreeSet<String>
pub fn accessed_fields(&self) -> &BTreeSet<String>
Returns the set of field names accessed by this method.
§Examples
use std::collections::BTreeSet;
use whitaker_common::lcom4::MethodInfo;
let m = MethodInfo::new(
"read",
BTreeSet::from(["buf".into()]),
BTreeSet::new(),
);
assert!(m.accessed_fields().contains("buf"));Sourcepub fn called_methods(&self) -> &BTreeSet<String>
pub fn called_methods(&self) -> &BTreeSet<String>
Returns the set of method names called directly by this method.
§Examples
use std::collections::BTreeSet;
use whitaker_common::lcom4::MethodInfo;
let m = MethodInfo::new(
"process",
BTreeSet::new(),
BTreeSet::from(["validate".into()]),
);
assert!(m.called_methods().contains("validate"));Trait Implementations§
Source§impl Clone for MethodInfo
impl Clone for MethodInfo
Source§fn clone(&self) -> MethodInfo
fn clone(&self) -> MethodInfo
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MethodInfo
impl Debug for MethodInfo
impl Eq for MethodInfo
Source§impl PartialEq for MethodInfo
impl PartialEq for MethodInfo
impl StructuralPartialEq for MethodInfo
Auto Trait Implementations§
impl Freeze for MethodInfo
impl RefUnwindSafe for MethodInfo
impl Send for MethodInfo
impl Sync for MethodInfo
impl Unpin for MethodInfo
impl UnsafeUnpin for MethodInfo
impl UnwindSafe for MethodInfo
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