pub fn add_raw_function(
      &mut self,
      name: &str,
      parameter_count: impl Into<Option<u16>>,
      f: FunctionKind,
   ) -> Result<(), Error> {
      let global_id = name.to_global_id(&mut self.env)?;
      let function_id = self
         .env
         .create_function(Function {
            name: Rc::from(name),
            parameter_count: parameter_count.into(), // doesn't matter for non-methods
            kind: f,
         })
         .map_err(|_| Error::TooManyFunctions)?;
      let function = RawValue::from(self.gc.allocate(Closure {
         function_id,
         captures: Vec::new(),
      }));
      self.globals.set(global_id.0, function);
      Ok(())
   }
/// Declares a "raw" function in the global scope. Raw functions do not perform any type checks
/// by default and accept a variable number of arguments.
///
/// You should generally prefer [`add_function`][`Self::add_function`] instead of this.
///
/// Note that this cannot accept [`GlobalId`]s, because a name is required to create the function
/// and global IDs have their name erased.
///
/// `parameter_count` should reflect the parameter count of the function. Pass `None` if the
/// function accepts a variable number of arguments. Note that because this function omits type
/// checks you may receive a different amount of arguments than specified.
///
/// # Errors
///  - [`Error::TooManyGlobals`] - Too many globals with unique names were created
///  - [`Error::TooManyFunctions`] - Too many functions were registered into the engine
Declares a "raw" function in the global scope. Raw functions do not perform any type checks
by default and accept a variable number of arguments.

You should generally prefer [`add_function`][`Self::add_function`] instead of this.

Note that this cannot accept [`GlobalId`]s, because a name is required to create the function
and global IDs have their name erased.

`parameter_count` should reflect the parameter count of the function. Pass `None` if the
function accepts a variable number of arguments. Note that because this function omits type
checks you may receive a different amount of arguments than specified.
Declares a " raw " function in the global scope . Raw functions do not perform any type checks by default and accept a variable number of arguments . You should generally prefer [ ` add_function ` ] [ ` Self :: add_function ` ] instead of this . Note that this cannot accept [ ` GlobalId ` ] s because a name is required to create the function and global IDs have their name erased . ` parameter_count ` should reflect the parameter count of the function . Pass ` None ` if the function accepts a variable number of arguments . Note that because this function omits type checks you may receive a different amount of arguments than specified .
pub fn add_raw_function(
      &mut self,
      name: &str,
      parameter_count: impl Into<Option<u16>>,
      f: FunctionKind,
   ) -> Result<(), Error> {
      let global_id = name.to_global_id(&mut self.env)?;
      let function_id = self
         .env
         .create_function(Function {
            name: Rc::from(name),
            parameter_count: parameter_count.into(), // doesn't matter for non-methods
            kind: f,
         })
         .map_err(|_| Error::TooManyFunctions)?;
      let function = RawValue::from(self.gc.allocate(Closure {
         function_id,
         captures: Vec::new(),
      }));
      self.globals.set(global_id.0, function);
      Ok(())
   }
pub fn add_raw_function ( & mut self , name : & str , parameter_count : impl Into < Option < u16 > > , f : FunctionKind , ) -> Result < ( ) , Error > { let global_id = name . to_global_id ( & mut self . env ) ? ; let function_id = self . env . create_function ( Function { name : Rc :: from ( name ) , parameter_count : parameter_count . into ( ) , // doesn't matter for non-methods kind : f , } ) . map_err ( | _ | Error :: TooManyFunctions ) ? ; let function = RawValue :: from ( self . gc . allocate ( Closure { function_id , captures : Vec :: new ( ) , } ) ) ; self . globals . set ( global_id . 0 , function ) ; Ok ( ( ) ) }
Declares a "raw" function in the global scope.
Declares a " raw " function in the global scope .
&mut self
name
&str
parameter_count
impl Into<Option<u16>>
f
FunctionKind
errors
[`Error::TooManyGlobals`] - Too many globals with unique names were created
[`Error::TooManyFunctions`] - Too many functions were registered into the engine
[ ` Error :: TooManyGlobals ` ] - Too many globals with unique names were created [ ` Error :: TooManyFunctions ` ] - Too many functions were registered into the engine