Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

() not Serializable #88

Open
Open

Description

@Sushisource

Hey all, starting playing around with this, looks very cool.

Ran into the problem in the title almost right away though, which was rather surprising. I assume just an oversight, but would be nice to have.

Additionally when I first tried writing a generic Serializable struct, I added bounds to the generic for T: Serializable which I would expect to be necessary, but the macro seems to break on that (and if you remove it, appears to silently enforce it). It'd be good to allow that, or have a more explicit error.

Thanks!

Activity

  1. changed the title [-]`()` not `Serializeable`[/-] [+]`()` not `Serializable`[/+] on Mar 31, 2022
  2. added
    enhancement
    good first issue
    on Mar 31, 2022
  3. emschwartz commented on Apr 1, 2022

    @emschwartz
    Contributor

    Based on @arendjr adding the good first issue label, I think he's saying that yes this is indeed an oversight :) Thanks for reporting the issue!

  4. sagacity commented on Jul 4, 2022

    @sagacity
    Contributor

    I'll pick this up.

  5. sagacity commented on Jul 4, 2022

    @sagacity
    Contributor

    @Sushisource could you share the struct definition that wasn't working for you?

  6. Sushisource commented on Jul 5, 2022

    @Sushisource
    Author

    Even just this will do it:

    use fp_bindgen::prelude::*;
    
    #[derive(Serializable)]
    struct Foo {
        hi: ()
    }

    Results in:

    λ  cargo build
       Compiling rust-scratch v0.1.0 (/mnt/chonky/dev/rust-scratch)
    error: proc-macro derive panicked
     --> src/main.rs:9:10
      |
    9 | #[derive(Serializable)]
      |          ^^^^^^^^^^^^
      |
      = help: message: Only value types are supported. Incompatible type in struct field: Field { attrs: [], vis: Inherited, ident: Some(Ident { ident: "hi", span: #0 bytes(158..160) }), colon_token: Some(Colon), ty: Tuple(TypeTuple { paren_token: Paren, elems: [] }) }
    
  7. sagacity commented on Jul 6, 2022

    @sagacity
    Contributor

    @Sushisource thanks for sharing. I'm currently doing some work to allow unit types to be used in return types (e.g. Result<(), Error>). Do you have a use case for having unit fields in a struct? Otherwise I'm not sure we'd want to support that.

  8. Sushisource commented on Jul 6, 2022

    @Sushisource
    Author

    Yeah, the use case is a generic struct like this:

    use fp_bindgen::prelude::*;
    
    #[derive(Serializable)]
    struct Foo<T> {
        hi: T
    }

    Where some reification of that struct might reasonably want to use the unit type because it happens not to care about populating that field meaningfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions