pub fn ty<T>(&mut self) -> Result<(), ContextError>
    where
        T: Named + TypeOf + InstallWith,
    {
        let type_hash = T::type_hash();
        let type_info = T::type_info();

        let ty = ModuleType {
            name: T::full_name().into_boxed_str(),
            type_info,
        };

        if let Some(old) = self.types.insert(type_hash, ty) {
            return Err(ContextError::ConflictingType {
                item: Item::with_item(&[T::full_name()]),
                existing: old.type_info,
            });
        }
        T::install_with(self)?;
        Ok(())
    }
/// Register a type. Registering a type is mandatory in order to register
/// instance functions using that type.
///
/// This will allow the type to be used within scripts, using the item named
/// here.
///
/// # Examples
///
/// ```rust
/// use runestick::Any;
///
/// #[derive(Any)]
/// struct MyBytes {
///     queue: Vec<String>,
/// }
///
/// impl MyBytes {
///     fn len(&self) -> usize {
///         self.queue.len()
///     }
/// }
///
/// # fn main() -> runestick::Result<()> {
/// // Register `len` without registering a type.
/// let mut module = runestick::Module::default();
/// // Note: cannot do this until we have registered a type.
/// module.inst_fn("len", MyBytes::len)?;
///
/// let mut context = runestick::Context::new();
/// assert!(context.install(&module).is_err());
///
/// // Register `len` properly.
/// let mut module = runestick::Module::default();
///
/// module.ty::<MyBytes>()?;
/// module.inst_fn("len", MyBytes::len)?;
///
/// let mut context = runestick::Context::new();
/// assert!(context.install(&module).is_ok());
/// # Ok(()) }
/// ```
Register a type. Registering a type is mandatory in order to register
instance functions using that type.

This will allow the type to be used within scripts, using the item named
here.
Register a type . Registering a type is mandatory in order to register instance functions using that type . This will allow the type to be used within scripts using the item named here .
pub fn ty<T>(&mut self) -> Result<(), ContextError>
    where
        T: Named + TypeOf + InstallWith,
    {
        let type_hash = T::type_hash();
        let type_info = T::type_info();
        let ty = ModuleType {
            name: T::full_name().into_boxed_str(),
            type_info,
        };
        if let Some(old) = self.types.insert(type_hash, ty) {
            return Err(ContextError::ConflictingType {
                item: Item::with_item(&[T::full_name()]),
                existing: old.type_info,
            });
        }
        T::install_with(self)?;
        Ok(())
    }
pub fn ty < T > ( & mut self ) -> Result < ( ) , ContextError > where T : Named + TypeOf + InstallWith , { let type_hash = T :: type_hash ( ) ; let type_info = T :: type_info ( ) ; let ty = ModuleType { name : T :: full_name ( ) . into_boxed_str ( ) , type_info , } ; if let Some ( old ) = self . types . insert ( type_hash , ty ) { return Err ( ContextError :: ConflictingType { item : Item :: with_item ( & [ T :: full_name ( ) ] ) , existing : old . type_info , } ) ; } T :: install_with ( self ) ? ; Ok ( ( ) ) }
Register a type.
Register a type .
&mut self
&mut self
examples
```rust
use runestick::Any.
` ` ` rust use runestick :: Any .
[derive(any)]
struct MyBytes {
queue: Vec,
}

impl MyBytes {
fn len(&self) -> usize {
self.queue.len()
}
}
struct MyBytes { queue : Vec } impl MyBytes { fn len ( &self ) - > usize { self . queue . len () } }
fn main() -> runestick::result<()> {
Register `len` without registering a type.
let mut module = runestick::Module::default();
Note: cannot do this until we have registered a type.
module.inst_fn("len", MyBytes::len)?.

let mut context = runestick::Context::new();
assert!(context.install(&module).is_err()).

Register `len` properly.
let mut module = runestick::Module::default().



let mut context = runestick::Context::new();
assert!(context.install(&module).is_ok()).
Register ` len ` without registering a type . let mut module = runestick :: Module :: default () ; Note : cannot do this until we have registered a type . module . inst_fn ( " len " MyBytes :: len ) ? . let mut context = runestick :: Context :: new () ; assert! ( context . install ( &module ) . is_err () ) . Register ` len ` properly . let mut module = runestick :: Module :: default () . let mut context = runestick :: Context :: new () ; assert! ( context . install ( &module ) . is_ok () ) .
ok(()) }
None