• cetra3@lemmy.mlOP
    link
    fedilink
    arrow-up
    2
    ·
    1 year ago

    Oh nooooo I’ve been discovered posting to reddit! 😯 We need to really post more rust content here, there’s barely anything.

    Yeah I just used anyhow instead of thiserror as that’s what I’m using on divedb.

    I’m not sure about the impl thing, care to elaborate?

    • RunAwayFrog@sh.itjust.works
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      I’m not sure about the impl thing, care to elaborate?

      See this serde-derive code.

      Basically, you’re wrapping your impl in a dummy const, so your impl lives in its own lexical scope.

      You can set attributes on that scope, define consts/statics, import stuff that will not interfere with anything outside the generated code…etc.

      So, just add your use lines. You can allow unused imports on the scope too, no conditional imports needed to avoid warnings. You don’t have to worry about anything 😉