#1: Add some basic recursion detection
Diff
stork/src/lib.rs | 17 +++++++++++++++--
stork_http/src/lib.rs | 5 +++++
2 files changed, 20 insertions(+), 2 deletions(-)
@@ -55,7 +55,7 @@ pub struct Storkable<T: Unpin, C: StorkClient<T>> {
parent: Option<Arc<Storkable<T, C>>>,
}
impl<'a, T: Unpin + 'a, C: StorkClient<T> + 'a> Storkable<T, C> {
impl<'a, T: Unpin + PartialEq + 'a, C: StorkClient<T> + 'a> Storkable<T, C> {
pub fn new(val: T) -> Self {
@@ -108,13 +108,26 @@ impl<'a, T: Unpin + 'a, C: StorkClient<T> + 'a> Storkable<T, C> {
try_stream! {
let mut children = this.client.run(this.val());
while let Some(child) = children.next().await {
'child: while let Some(child) = children.next().await {
let child = child.context(StorkError::ClientError)?;
if !this.filters.matches(&child) {
continue;
}
let mut current_parent = this.parent();
while let Some(parent) = current_parent {
if parent.value == this.value {
continue 'child;
}
current_parent = parent.parent();
}
yield Storkable {
value: child,
client: Arc::clone(&this.client),
@@ -105,6 +105,11 @@ impl Link {
self.text.clone()
}
}
impl PartialEq for Link {
fn eq(&self, other: &Self) -> bool {
self.url().as_str() == other.url().as_str()
}
}
impl std::str::FromStr for Link {
type Err = failure::Error;