Skip to content

Commit

Permalink
fix: use explicit lifetime in return types forRule::name and `Rule:…
Browse files Browse the repository at this point in the history
…:namespace`

This makes the API more flexible, as it tells the compiler that you can hold the reference as long as the compiled `Rules` object exists, and the `Rule` object can be freed while those references are still held.
  • Loading branch information
plusvic committed Nov 20, 2023
1 parent d33446b commit ebcd580
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions yara-x/src/scanner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,12 +809,12 @@ pub struct Rule<'a, 'r> {

impl<'a, 'r> Rule<'a, 'r> {
/// Returns the rule's name.
pub fn name(&self) -> &str {
pub fn name(&self) -> &'r str {
self.rules.ident_pool().get(self.rule_info.ident_id).unwrap()
}

/// Returns the rule's namespace.
pub fn namespace(&self) -> &str {
pub fn namespace(&self) -> &'r str {
self.rules.ident_pool().get(self.rule_info.namespace_ident_id).unwrap()
}

Expand Down

0 comments on commit ebcd580

Please sign in to comment.