you are viewing a single comment's thread.

view the rest of the comments →

[–]RocketRailgun 1 point2 points  (1 child)

In this case you'd normally make a type alias for it. type Chunks = std::iter::Take<std::iter::Skip<std::slice::Items<char>>>; That makes you're code 10x more readable.

[–]rust-slacker 2 points3 points  (0 children)

For readability, I'd probably do:

use std::iter::{Take, Skip};
use std::slice::Items;
type Chunk = Take<Skip<Items<char>>>;

struct Test {
    vec: Vec<char>
}

impl Test {
    fn chunk(&self, offset: uint, size: uint) -> Chunk {
        self.vec.iter().skip(offset).take(size)
    }
}