tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.
https://turso.tech/libsql
MIT License
11.28k stars 286 forks source link

Generate `Eitherxx` variants #1438

Closed avinassh closed 5 months ago

avinassh commented 5 months ago

This PR adds a macro which generates a drop in replacement of Either enum:

pub enum Either<L, R> {
    Left(L),
    Right(R),
}

It is generated by create_either!(Either<A, B>).

The Either enum is used in libsql-server to hold two kinds of different WALs. This macro generates enum variants which can hold any number of WALs. This makes it easy to plug different WALs in the future.