Code Monkey home page Code Monkey logo

tuplez's Introduction

tuplez

This crate introduces a tuple type represented in recursive form rather than parallel form.

Motivation

The primitive tuple types are represented in parallel form, like:

(a, b, c, d ...)

Since Rust doesn't support variadic generics, we cannot add methods to primitive tuples with any number of elements.

Currently, most tuple crates use declarative macros to implement methods for tuples whose number of elements is less than a certain limit (usually 32).

To solve this, tuplez introduces a Tuple type represented in recursive form, like:

Tuple(a, Tuple(b, Tuple(c, Tuple(d, ...))))

The advantage of this representation is that you can implement methods recursively for all tuples, and there is no longer a limit on the number of tuple's elements. And, in almost all cases, the Tuple takes no more memory than the primitive tuples.

Functionality

  • Create tuples with any number of elements.
  • Access elements in a tuple at any index, or by their types.
  • Push element to a tuple or pop element from a tuple.
  • Join two tuples or split a tuple into two parts.
  • Rich tuple operations, e.g.: reverse, left rotate, zip.
  • Get subsequences.
  • If all element types implement a Trait (e.g. Eq, Add), then the Tuple also implement that Trait.
  • Traverse all elements of a tuple, or fold a tuple.
  • When the number of elements of a tuple doesn't exceed 32, then it can be converted from/to a primitive tuple or a primitive array.

Please check the documentation for details.

tuplez's People

Contributors

nichtshsu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.