Skip to content

Impl MaxSize for heapless::Vec #198

@HaoboGu

Description

@HaoboGu

Hello, is it possible to implement MaxSize for heapless::Vec? I found that Se/De traits are already implemented, but MaxSize does not:

My Cargo.toml:

heapless = {version = "0.8.0", features = ["serde"] }
postcard = { version = "1", features = ["experimental-derive", "use-defmt", "heapless"] }

My structs:

#[derive(Serialize, Deserialize, Clone, Debug, Format, MaxSize)]
pub struct A<const N: usize> {
    pub value: Vec<u8, N>
}

Error log:

error[E0277]: the trait bound `Vec<u8, N>: MaxSize` is not satisfied
  --> /Users/haobogu/Projects/keyboard/rmk/rmk/src/event.rs:29:16
   |
29 |     pub value: Vec<u8, N>
   |                ^^^^^^^^^^ the trait `MaxSize` is not implemented for `Vec<u8, N>`
   |
   = help: the following other types implement trait `MaxSize`:
             &T
             &mut T
             ()
             (A, B)
             (A, B, C)
             (A, B, C, D)
             (A, B, C, D, E)
             (A, B, C, D, E, F)
           and 41 others


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions