libsugar / tuplers Goto Github PK
View Code? Open in Web Editor NEWProvides many useful tools related to tuples
Home Page: https://crates.io/crates/tuples
License: MIT License
Provides many useful tools related to tuples
Home Page: https://crates.io/crates/tuples
License: MIT License
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), ()
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`
This would be useful for example in iterators to be able to clone both values and tuples with the same code
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.