Struct oso::ClassBuilder [−][src]
pub struct ClassBuilder<T> { /* fields omitted */ }
Implementations
Create a new class builder for a type that implements Default and use that as the constructor.
pub fn with_constructor<F, Args>(f: F) -> Self where
F: Function<Args, Result = T>,
T: Send + Sync,
Args: FromPolarList,
pub fn with_constructor<F, Args>(f: F) -> Self where
F: Function<Args, Result = T>,
T: Send + Sync,
Args: FromPolarList,
Create a new class builder with a given constructor.
pub fn set_constructor<F, Args>(self, f: F) -> Self where
F: Function<Args, Result = T>,
T: Send + Sync,
Args: FromPolarList,
pub fn set_constructor<F, Args>(self, f: F) -> Self where
F: Function<Args, Result = T>,
T: Send + Sync,
Args: FromPolarList,
Set the constructor function to use for polar new
statements.
Set an equality function to be used for polar ==
statements.
Set a method to convert instances into iterators
pub fn with_iter<V>(self) -> Self where
T: IntoIterator<Item = V> + Clone,
<T as IntoIterator>::IntoIter: Clone + Send + Sync + 'static,
V: ToPolarResult,
pub fn with_iter<V>(self) -> Self where
T: IntoIterator<Item = V> + Clone,
<T as IntoIterator>::IntoIter: Clone + Send + Sync + 'static,
V: ToPolarResult,
Use the existing IntoIterator
implementation to convert instances into iterators
Use PartialEq::eq as the equality check for polar ==
statements.
Add an attribute getter for statments like foo.bar
`class.add_attribute_getter(“bar”, |instance| instance.bar)
Add a RegisterHook on the class that will register the given constant once the class is registered.
pub fn add_method<F, Args, R>(self, name: &'static str, f: F) -> Self where
Args: FromPolarList,
F: Method<T, Args, Result = R>,
R: ToPolarResult + 'static,
pub fn add_method<F, Args, R>(self, name: &'static str, f: F) -> Self where
Args: FromPolarList,
F: Method<T, Args, Result = R>,
R: ToPolarResult + 'static,
Add a method for polar method calls like foo.plus(1)
class.add_attribute_getter(“bar”, |instance, n| instance.foo + n)
pub fn add_iterator_method<F, Args, I>(self, name: &'static str, f: F) -> Self where
Args: FromPolarList,
F: Method<T, Args>,
F::Result: IntoIterator<Item = I>,
I: ToPolarResult + 'static,
<<F as Method<T, Args>>::Result as IntoIterator>::IntoIter: Iterator<Item = I> + Clone + Send + Sync + 'static,
T: 'static,
pub fn add_iterator_method<F, Args, I>(self, name: &'static str, f: F) -> Self where
Args: FromPolarList,
F: Method<T, Args>,
F::Result: IntoIterator<Item = I>,
I: ToPolarResult + 'static,
<<F as Method<T, Args>>::Result as IntoIterator>::IntoIter: Iterator<Item = I> + Clone + Send + Sync + 'static,
T: 'static,
A method that returns multiple values. Every element in the iterator returned by the method will be a separate polar return value.
pub fn add_class_method<F, Args, R>(self, name: &'static str, f: F) -> Self where
F: Function<Args, Result = R>,
Args: FromPolarList,
R: ToPolarResult + 'static,
pub fn add_class_method<F, Args, R>(self, name: &'static str, f: F) -> Self where
F: Function<Args, Result = R>,
Args: FromPolarList,
R: ToPolarResult + 'static,
A method that’s called on the type instead of an instance.
eg Foo.pi
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for ClassBuilder<T>
impl<T> Send for ClassBuilder<T> where
T: Send,
impl<T> Sync for ClassBuilder<T> where
T: Sync,
impl<T> Unpin for ClassBuilder<T> where
T: Unpin,
impl<T> !UnwindSafe for ClassBuilder<T>
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more