fn create<F>(f: F) -> Addr<Self>
    where
        Self: Actor<Context = Context<Self>>,
        F: FnOnce(&mut Context<Self>) -> Self,
    {
        let mut ctx = Context::new();
        let act = f(&mut ctx);
        ctx.run(act)
    }
/// Start a new asynchronous actor given a `Context`.
///
/// Use this method if you need the `Context` object during actor
/// initialization.
///
/// # Examples
///
/// ```
/// use actix::*;
///
/// struct MyActor {
///     val: usize,
/// }
/// impl Actor for MyActor {
///     type Context = Context<Self>;
/// }
///
/// fn main() {
///     // initialize system
///     System::new().block_on(async {
///         let addr = MyActor::create(|ctx: &mut Context<MyActor>| MyActor { val: 10 });
/// #       System::current().stop();
///     });
/// }
/// ```
Start a new asynchronous actor given a `Context`.
Use this method if you need the `Context` object during actor
initialization.
Start a new asynchronous actor given a ` Context ` . Use this method if you need the ` Context ` object during actor initialization .
fn create<F>(f: F) -> Addr<Self>
    where
        Self: Actor<Context = Context<Self>>,
        F: FnOnce(&mut Context<Self>) -> Self,
    {
        let mut ctx = Context::new();
        let act = f(&mut ctx);
        ctx.run(act)
    }
fn create < F > ( f : F ) -> Addr < Self > where Self : Actor < Context = Context < Self > > , F : FnOnce ( & mut Context < Self > ) -> Self , { let mut ctx = Context :: new ( ) ; let act = f ( & mut ctx ) ; ctx . run ( act ) }
Start a new asynchronous actor given a `Context`.
Start a new asynchronous actor given a ` Context ` .
f
F
f
F
examples


struct MyActor {
val: usize,
}
impl Actor for MyActor {
type Context = Context;
}

fn main() {
initialize system
System::new().block_on(async {
let addr = MyActor::create(|ctx: &mut Context| MyActor { val: 10 }).
struct MyActor { val : usize } impl Actor for MyActor { type Context = Context ; } fn main () { initialize system System :: new () . block_on ( async { let addr = MyActor :: create ( |ctx : &mut Context| MyActor { val : 10 } ) .
system::current().stop();
None