Coder Social home page Coder Social logo

context_iterators's Introduction

context-iterators

build_status crates msrv

Iterators adaptors with associated read-only data.

Useful for naming the types of wrapped iterators by using function pointers or non-capturing closures.

use context_iterators::*;
use std::ops::Range;

type MappedIterator = MapCtx<WithCtx<Range<u16>, u16>, usize>;

let iter: MappedIterator = (0..10)
    .with_context(42)
    .map_with_context(|item: u16, context: &u16| (item + *context) as usize);

assert!(iter.eq(42..52));

The MappedIterator type can be used in contexts where a concrete type is needed, for example as an associated type for a trait.

trait Iterable {
    type Iter: Iterator<Item = usize>;
}

struct MyIterable;

impl Iterable for MyIterable {
   type Iter = MappedIterator;
}

Please read the API documentation here.

Recent Changes

See CHANGELOG for a list of changes. The minimum supported rust version will only change on major releases.

License

This project is dual-licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 or the MIT license http://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.

context_iterators's People

Contributors

aborgna avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.