     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44

    use std::mem;
    use std::ops::{Deref, DerefMut};

    use crate::base::allocator::Allocator;
    use crate::base::coordinates::{X, XY, XYZ, XYZW, XYZWA, XYZWAB};
    use crate::base::dimension::{U1, U2, U3, U4, U5, U6};
    use crate::base::{DefaultAllocator, Scalar};

    use crate::geometry::Translation;

    /*
     *
     * Give coordinates to Translation{1 .. 6}
     *
     */

    macro_rules! deref_impl(
        ($D: ty, $Target: ident $(, $comps: ident)*) => {
            impl<N: Scalar> Deref for Translation<N, $D>
                where DefaultAllocator: Allocator<N, $D> {
                type Target = $Target<N>;

                #[inline]
                fn deref(&self) -> &Self::Target {
                    unsafe { mem::transmute(self) }
                }
            }

            impl<N: Scalar> DerefMut for Translation<N, $D>
                where DefaultAllocator: Allocator<N, $D> {
                #[inline]
                fn deref_mut(&mut self) -> &mut Self::Target {
                    unsafe { mem::transmute(self) }
                }
            }
        }
    );

    deref_impl!(U1, X, x);
    deref_impl!(U2, XY, x, y);
    deref_impl!(U3, XYZ, x, y, z);
    deref_impl!(U4, XYZW, x, y, z, w);
    deref_impl!(U5, XYZWA, x, y, z, w, a);
    deref_impl!(U6, XYZWAB, x, y, z, w, a, b);

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)