https://github.com/timboudreau/into_tuple
A trivial rust library for converting abitrarily sized arrays into correspondingly sized tuples
https://github.com/timboudreau/into_tuple
Last synced: 3 months ago
JSON representation
A trivial rust library for converting abitrarily sized arrays into correspondingly sized tuples
- Host: GitHub
- URL: https://github.com/timboudreau/into_tuple
- Owner: timboudreau
- License: mit
- Created: 2024-05-06T19:00:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-06T19:51:55.000Z (over 1 year ago)
- Last Synced: 2025-01-10T15:50:56.479Z (about 1 year ago)
- Language: Rust
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
into_tuple
==========
A trivial Rust crate which provides a trait and implementations of it for converting Rust const-sized arrays
into Rust tuples, e.g.
```rust
let arr = [1_usize, 2_usize, 3_usize];
let tuple : (&usize, &usize, &usize) = arr.into_tuple();
assert_eq!((1_usize, 2_usize, 3_usize), tuple);
```
or with borrows
```rust
let arr = [1_usize, 2_usize, 3_usize];
let borrowed = &arr;
let tuple : (&usize, &usize, &usize) = borrowed.into_tuple();
```
The library has a hard maximum dimension which it will convert, since there need to be specific, generated
implementations for each possible dimension. The default maximum is a size of 12.
The (mutually exclusive) feature flags `medium`, `large` and `huge` allow building it to support 24, 64 or 250
element arrays/tuples. Given the readability of such code would be less than great, the larger sizes are mainly
of use in or calling other generated code.
Publishing on crates.io
-----------------------
While this was intended to be published there, I have yet to find a strategy that works to generate
the sources to a library, and not have `cargo publish` fail it, or have tests not able to `use` types
from the crate. Pending.
License
-------
MIT license - do what thou wilt.