Git Product home page Git Product logo

tuplers's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tuplers's Issues

Allow splitting tuples

Given a tuple (A, B, C), I'd like to be able to split it into two in the following ways:

(), (A, B, C)
(A,), (B, C)
(A, B), (C,)
(A, B, C), ()

Implement `TupleAsRef`, etc. for `()`

It would only return (), but for completion's sake it should be implemented. I'm currently getting errors in a program because this doesn't compile if the tuple is ():

Reproduce with (dependencies tuples and tuple-fn):

use tuples::tuple_as::TupleAsRef;
use tuple_fn::TupleFn;

fn call_closure_on_tuple<'a, T, F>(tuple: &'a T, func: F)
where T: TupleAsRef<'a> + 'a,
      F: TupleFn<<T as TupleAsRef<'a>>::OutTuple, TupleFnOutput = ()>,
{
    func.call_with_args_tuple(tuple.as_ref())
}

fn main() {
    call_closure_on_tuple(&(), || {
        println!("Hello, world!");
    })
}

Error:

error[E0277]: the trait bound `(): TupleAsRef<'_>` is not satisfied
  --> src/main.rs:12:27
   |
12 |     call_closure_on_tuple(&(), || {
   |     --------------------- ^^^ the trait `TupleAsRef<'_>` is not implemented for `()`
   |     |
   |     required by a bound introduced by this call
   |
   = help: the following other types implement trait `TupleAsRef<'a>`:
             (T,)
             (T0, T1)
             (T0, T1, T2)
             (T0, T1, T2, T3)
             (T0, T1, T2, T3, T4)
             (T0, T1, T2, T3, T4, T5)
             (T0, T1, T2, T3, T4, T5, T6)
             (T0, T1, T2, T3, T4, T5, T6, T7)
           and 24 others
note: required by a bound in `call_closure_on_tuple`
  --> src/main.rs:5:10
   |
4  | fn call_closure_on_tuple<'a, T, F>(tuple: &'a T, func: F)
   |    --------------------- required by a bound in this
5  | where T: TupleAsRef<'a> + 'a,
   |          ^^^^^^^^^^^^^^ required by this bound in `call_closure_on_tuple`

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.