Skip to content

Commit

Permalink
#73 mutable relay
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jan 11, 2023
1 parent cc691b2 commit af43dc7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::collections::VecDeque;
use std::str::FromStr;

impl Relay for DeadRelay {
fn re(&self, v: u32, a: &str, b: &str) -> Result<String> {
fn re(&mut self, v: u32, a: &str, b: &str) -> Result<String> {
Err(anyhow!("Can't find {a}/{b} at ν{v}"))
}
}
Expand Down Expand Up @@ -56,7 +56,7 @@ impl LambdaRelay {
}

impl Relay for LambdaRelay {
fn re(&self, v: u32, a: &str, b: &str) -> Result<String> {
fn re(&mut self, v: u32, a: &str, b: &str) -> Result<String> {
(self.lambda)(v, a, b)
}
}
Expand All @@ -83,7 +83,7 @@ impl Sodg {
///
/// If target vertex is not found or `v1` is absent,
/// an `Err` will be returned.
pub fn find<T: Relay + Copy>(&self, v1: u32, loc: &str, relay: T) -> Result<u32> {
pub fn find<T: Relay + Copy>(&self, v1: u32, loc: &str, mut relay: T) -> Result<u32> {
let mut v = v1;
let mut locator: VecDeque<String> = VecDeque::new();
loc.split('.')
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub struct Sodg {
/// Pretty much anything that the relay returns will be used
/// as a new search string, starting from the `v` vertex.
pub trait Relay {
fn re(&self, v: u32, a: &str, b: &str) -> Result<String>;
fn re(&mut self, v: u32, a: &str, b: &str) -> Result<String>;
}

/// This `Relay` doesn't even try to find anything, but returns
Expand Down

0 comments on commit af43dc7

Please sign in to comment.