Reputation: 105203
I'm trying to do this, but it doesn't work:
struct Pack {
data: Box<[u8]>
}
fn foo() {
let mut p = Pack {
data: Box::new(**b"Hello!")
};
p.data.set(b"Bye!");
}
I'm getting:
error[E0614]: type `[u8; 6]` cannot be dereferenced
--> foo
|
30 | data: Box::new(**b"Hello!")
| ^^^^^^^^^^^
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> foo
|
30 | data: Box::new(**b"Hello!")
| ^^^^^^^^ doesn't have a size known at compile-time
|
What is the right way to do this?
Upvotes: 1
Views: 306