tuplities_ref/
lib.rs

1#![no_std]
2
3//! [tuplities](https://github.com/lucacappelletti94/tuplities) suite crate providing the `TupleRef` trait.
4
5#[tuplities_derive::impl_tuple_ref]
6/// A trait for tuples that provides a method to get a tuple of references.
7///
8/// This trait provides both an associated type `Ref<'a>` that represents a tuple
9/// of references to the elements, and a method `tuple_ref` that returns such a tuple.
10///
11/// # Examples
12///
13/// ```rust
14/// use tuplities_ref::TupleRef;
15///
16/// let tuple = (1, "hello".to_string(), vec![1, 2, 3]);
17/// let refs = tuple.tuple_ref();
18/// assert_eq!(refs, (&1, &"hello".to_string(), &vec![1, 2, 3]));
19/// ```
20///
21/// Part of the [`tuplities`](https://docs.rs/tuplities/latest/tuplities/) crate.
22pub trait TupleRef {
23    /// The type of a tuple containing references to each element.
24    type Ref<'a>
25    where
26        Self: 'a;
27
28    /// Returns a tuple of references to each element.
29    ///
30    /// # Examples
31    ///
32    /// ```rust
33    /// use tuplities_ref::TupleRef;
34    ///
35    /// let tuple = (42, "world");
36    /// let refs = tuple.tuple_ref();
37    /// assert_eq!(refs, (&42, &"world"));
38    /// ```
39    fn tuple_ref(&self) -> Self::Ref<'_>;
40}