Skip to content

Why not remove trait FnBox ? #106

@zydxhs

Description

@zydxhs

FnOnce already replaces FnBox, so why implement it yourself?

  1. 删除以下代码:
trait FnBox {
    fn call_box(self: Box<Self>);
}

impl<F: FnOnce()> FnBox for F {
    fn call_box(self: Box<F>) {
        (*self)()
    }
}
  1. 修改代码
type Thunk<'a> = Box<FnBox + Send + 'a>;

改成

type Thunk<'a> = Box<dyn FnOnce() -> () + Send + 'a>;
job.call_box();

改成

job();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions