Skip to content

add generics support#33

Open
Jezza wants to merge 1 commit intosurrealdb:mainfrom
Jezza:jezza/generics
Open

add generics support#33
Jezza wants to merge 1 commit intosurrealdb:mainfrom
Jezza:jezza/generics

Conversation

@Jezza
Copy link
Copy Markdown

@Jezza Jezza commented Aug 26, 2025

Adds support for generic enums and structs.

So the example from the doc could work like this:

    #[derive(Debug, PartialEq)]
    #[revision::revisioned(revision = 3)]
    pub enum TestEnum<T> {
        #[revision(end = 2, convert_fn = "upgrade_zero")]
        Zero,
        #[revision(end = 2, convert_fn = "upgrade_one")]
        One(T),
        #[revision(start = 2)]
        Two(u64),
        #[revision(start = 2)]
        Three {
            a: i64,
            #[revision(end = 2, convert_fn = "upgrade_three_b")]
            b: f32,
            #[revision(start = 2)]
            c: u32,
            #[revision(start = 3)]
            d: T
        },
    }

Probably not the cleanest code, as I was about halfway writing it when I realised I don't need that functionality.
but I thought I might as well get it working so you could choose to take it or not.

I'm happy to adjust any smaller things.

@tobiemh tobiemh force-pushed the main branch 7 times, most recently from cbd9441 to fb0fcc5 Compare December 8, 2025 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant