
use std::ops::RangeFrom;
use std::iter;
use std::num::{Float, NumCast};

/// An iterator of `n` evenly spaced floats.
///
/// Iterator element type is `F`.
pub type Linspace<F> = iter::Take<iter::StepBy<F, RangeFrom<F>>>;

/// Return an iterator with `n` elements, where the first
/// element is `a` and the last element is `b`.
///
/// Iterator element type is `F`.
///
/// ```
/// use itertools as it;
/// let mut xs = it::linspace::<f32>(0., 1., 5);
/// assert_eq!(xs.collect::<Vec<_>>(),
///            vec![0., 0.25, 0.5, 0.75, 1.0]);
/// ```
#[inline]
pub fn linspace<F>(a: F, b: F, n: usize) -> Linspace<F> where
    F: Float,
{
    let nf: F = NumCast::from(n).unwrap();
    let step = (b - a)/(nf - Float::one());
    (a..).step_by(step).take(n)
}


use std::iter;
use std::num::{Float, NumCast};

/// An iterator of `n` evenly spaced floats.
///
/// Iterator element type is `F`.
pub type Linspace<F> = iter::Take<iter::Counter<F>>;

/// Return an iterator with `n` elements, where the first
/// element is `a` and the last element is `b`.
///
/// Iterator element type is `F`.
///
/// ```
/// use itertools as it;
/// let mut xs = it::linspace::<f32>(0., 1., 5);
/// assert_eq!(xs.collect::<Vec<_>>(),
///            vec![0., 0.25, 0.5, 0.75, 1.0]);
/// ```
#[inline]
pub fn linspace<F>(a: F, b: F, n: usize) -> Linspace<F> where
    F: Float,
{
    let nf: F = NumCast::from(n).unwrap();
    let step = (b - a)/(nf - Float::one());
    iter::count(a, step).take(n)
}

--- 
+++ 
@@ -1,11 +1,12 @@
 
+use std::ops::RangeFrom;
 use std::iter;
 use std::num::{Float, NumCast};
 
 /// An iterator of `n` evenly spaced floats.
 ///
 /// Iterator element type is `F`.
-pub type Linspace<F> = iter::Take<iter::Counter<F>>;
+pub type Linspace<F> = iter::Take<iter::StepBy<F, RangeFrom<F>>>;
 
 /// Return an iterator with `n` elements, where the first
 /// element is `a` and the last element is `b`.
@@ -24,5 +25,5 @@
 {
     let nf: F = NumCast::from(n).unwrap();
     let step = (b - a)/(nf - Float::one());
-    iter::count(a, step).take(n)
+    (a..).step_by(step).take(n)
 }
Use .step_by instead of iter::counter
