Expand description
§Pair
A generic pair structure that holds two values of potentially different types.
§Examples
use qubit_common::Pair;
// Compare readability
let tuple = ("Alice", 30);
println!("Name: {}, Age: {}", tuple.0, tuple.1); // Less clear
let pair = Pair::new("Alice", 30);
println!("Name: {}, Age: {}", pair.first, pair.second); // More clear
// Method chaining with Pair
let result = Pair::new(5, "hello")
.map_first(|x| x * 2)
.map_second(|s| s.len());
assert_eq!(result, Pair::new(10, 5));
// Easy conversion between Pair and tuple
let tuple = (1, 2);
let pair: Pair<i32, i32> = tuple.into();
let back_to_tuple: (i32, i32) = pair.into();§Author
Haixing Hu
Structs§
- Pair
- A generic pair structure that holds two values.