Tuple Set

Ergonomic utilities for working with stable Rust tuples by unique type, not by position.

When implementing generic traits, you often care about a type inside a tuple rather than its position. The location may differ across tuple types and may not even be knowable. Tuple Set allows you to operate on tuple values by type when that type appears exactly once.

  • Fully no_std compatible
  • Zero dependencies
  • Works with tuples up to 64 elements (feature-gating can extend this)
  • Supports duplicated types in the same tuple as long as the target type is unique

Example

use tuple_set::TupleSet;

let mut tuple = (42i32, "hello", None::<&str>, "world", 3.14f64);

// Replace the i32 by type
assert!(tuple.set(100i32).is_none());
assert_eq!(tuple.0, 100);

// Make...

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help