Skip to content

lifetimes aren't fully supported #10

Open
@1xX69

Description

@1xX69
#[axum_codec::apply(encode, decode)]
pub struct HelpLink<'a> {
    pub description: &'a str,
}

#[axum_codec::apply(encode, decode)]
pub enum ErrorDetail<'a> {
    Help { links: Vec<HelpLink<'a>> },
}

fn main() {}
➜  monorepo git:(master) ✗ cargo build -p sample
   Compiling serde v1.0.217
   Compiling axum-core v0.5.0
   Compiling thiserror v1.0.69
   Compiling serde_json v1.0.138
   Compiling axum v0.8.1
   Compiling axum-codec v0.0.19
   Compiling sample v0.1.0 (/home/user/workspace/monorepo/sample)
error: lifetime may not live long enough
 --> sample/src/main.rs:8:12
  |
6 | #[axum_codec::apply(encode, decode)]
  | ------------------------------------ lifetime `'de` defined here
7 | pub enum ErrorDetail<'a> {
  |                      -- lifetime `'a` defined here
8 |     Help { links: Vec<HelpLink<'a>> },
  |            ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'de` must outlive `'a`
  |
  = help: consider adding the following bound: `'de: 'a`

error: could not compile `sample` (bin "sample") due to 2 previous errors

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