use std::sync::Arc;
pub type A = Arc<dyn Fn(dyn FnOnce(&mut [u8]), usize) -> Result<(), ()> + Send + Sync>;
pub struct B {
a: A,
}
Gives
Compiling playground v0.0.1 (/playground)
error[E0277]: the size for values of type `(dyn for<'r> FnOnce(&'r mut [u8]) + 'static)` cannot be known at compilation time
--> src/lib.rs:5:8
|
5 | a: A,
| ^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn for<'r> FnOnce(&'r mut [u8]) + 'static)`
= note: only the last element of a tuple may have a dynamically sized type
I think Arc has a size know at compile time. dyn Fn has, at least when I do pub type A = Arc<dyn Fn() -> Result<(), ()> + Send + Sync>;. However, when I put dyn FnOnce(&mut [u8]) inside dyn Dn, the size cannot be known.
Why pub type A = Arc<dyn Fn() -> Result<(), ()> + Send + Sync>; is ok but not pub type A = Arc<dyn Fn(dyn FnOnce(&mut [u8]), usize) -> Result<(), ()> + Send + Sync>;?