 Comprehensive Rust(日语) 202412shared reference to the closure, which means the closure can be executed repeatedly and even concurrently. An FnMut (e.g. accumulate) might mutate captured values. The closure object is accessed via exclusive concurrently. If you have an FnOnce (e.g. multiply_sum), you may only call it once. Doing so consumes the closure and any values captured by move. FnMut は FnOnce のサブタイプで、Fn は FnMut と FnOnce のサブタイプです。つまり、FnOnce を使用するようにします。これにより、呼び出し元に最も柔軟に対応できます。 In contrast, when you have a closure, the most flexible you can have is Fn (which can be passed to a consumer of any of the 3 closure traits), then FnMut, and lastly FnOnce. The compiler0 码力 | 381 页 | 1.36 MB | 10 月前3 Comprehensive Rust(日语) 202412shared reference to the closure, which means the closure can be executed repeatedly and even concurrently. An FnMut (e.g. accumulate) might mutate captured values. The closure object is accessed via exclusive concurrently. If you have an FnOnce (e.g. multiply_sum), you may only call it once. Doing so consumes the closure and any values captured by move. FnMut は FnOnce のサブタイプで、Fn は FnMut と FnOnce のサブタイプです。つまり、FnOnce を使用するようにします。これにより、呼び出し元に最も柔軟に対応できます。 In contrast, when you have a closure, the most flexible you can have is Fn (which can be passed to a consumer of any of the 3 closure traits), then FnMut, and lastly FnOnce. The compiler0 码力 | 381 页 | 1.36 MB | 10 月前3
共 1 条
- 1













