#[derive(Index)]
{
// Attributes available to this derive:
#[debug]
#[index]
}
Expand description
Provides an automatic Index trait implementation when-ever it’s possible.
This macro simplifies the indexing syntax of struct type.
§Example Usage
Instead of manually implementing Index< T > for IsTransparent:
use core::ops::Index;
pub struct IsTransparent< T >
{
a : Vec< T >,
}
impl< T > Index< usize > for IsTransparent< T >
{
type Output = T;
#[ inline( always ) ]
fn index( &self, index : usize ) -> &Self::Output
{
&self.a[ index ]
}
}Use #[ index ] to automatically generate the implementation:
use derive_tools_meta::*;
#[ derive( Index ) ]
pub struct IsTransparent< T >
{
#[ index ]
a : Vec< T >
};