mirror of
https://github.com/guilhermewerner/reflection
synced 2025-06-16 21:44:19 +00:00
Test generics and other things
This commit is contained in:
38
Source/Examples/Array.rs
Normal file
38
Source/Examples/Array.rs
Normal file
@ -0,0 +1,38 @@
|
||||
use crate::*;
|
||||
|
||||
#[derive(Reflect)]
|
||||
pub struct Array<T>
|
||||
where
|
||||
T: Reflect,
|
||||
{
|
||||
inner: Vec<T>,
|
||||
}
|
||||
|
||||
impl<T> Default for Array<T>
|
||||
where
|
||||
T: Reflect,
|
||||
{
|
||||
fn default() -> Self {
|
||||
Self { inner: Vec::new() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Array<T>
|
||||
where
|
||||
T: Reflect,
|
||||
{
|
||||
#[function]
|
||||
pub fn New() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
#[function]
|
||||
pub fn Get(&mut self, index: usize) -> Option<&T> {
|
||||
self.inner.get(index)
|
||||
}
|
||||
|
||||
#[function]
|
||||
pub fn GetMut(&mut self, index: usize) -> Option<&mut T> {
|
||||
self.inner.get_mut(index)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user