Skip to content

Commit

Permalink
Don't cache iterators, as it occasionally throws errors
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Aug 29, 2024
1 parent 5328b90 commit 45b3f96
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 2 additions & 4 deletions rust/src/include/fibonacci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ use std::ops::{Add,Mul};

use num_traits::{one,zero,One,Zero};

use crate::include::iter_cache::cache_iterator;

pub fn fib<I>() -> impl Iterator<Item = I> where I: Copy + Zero + One + Add + 'static {
return cache_iterator(Fibonacci::<I>::new());
return Fibonacci::<I>::new();
}

pub fn fib_by_3<I>() -> impl Iterator<Item = I> where I: Copy + Zero + One + Add + Mul + 'static {
return cache_iterator(FibonacciBy3::<I>::new());
return FibonacciBy3::<I>::new();
}

#[derive(Clone, Copy, Debug, Hash)]
Expand Down
4 changes: 1 addition & 3 deletions rust/src/include/primes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use std::ops::{Add,Div,Mul,Rem};

use num_traits::{one,zero,One,Zero};

use crate::include::iter_cache::cache_iterator;

#[derive(Clone, Debug)]
pub struct Eratosthenes<I> where I: Hash {
sieve: HashMap<I, Vec<I>>,
Expand Down Expand Up @@ -62,7 +60,7 @@ impl<I> Iterator for Eratosthenes<I> where I: Hash + One + Zero + Add + Mul + Or
}

pub fn primes<I>() -> impl Iterator<Item = I> where I: Hash + One + Zero + Add + Mul + Ord + Copy + 'static {
return cache_iterator(Eratosthenes::new());
return Eratosthenes::new();
}

pub fn primes_until<I>(x: I) -> impl Iterator<Item = I> where I: Hash + One + Zero + Add + Mul + Ord + Copy + 'static {
Expand Down

0 comments on commit 45b3f96

Please sign in to comment.