#multiple #enums #place #singular #content #options #maybe-multiple

jdt_maybe_multiple

MaybeMultiple is a utility crate that establishes an enum to use in place of Option where the content may be singular, multiple, or None

3 releases

0.1.2 Jan 22, 2025
0.1.1 Jan 22, 2025
0.1.0 Jan 1, 2025

#1012 in Rust patterns

Download history 178/week @ 2024-12-29 78/week @ 2025-01-05 19/week @ 2025-01-12 306/week @ 2025-01-19 39/week @ 2025-01-26 13/week @ 2025-02-02

385 downloads per month
Used in 2 crates

MIT license

8KB
169 lines

MaybeMultiple

This is a utility crate that establishes an enum to use in place of Option where the content may be singular, multiple (a Vec) or None. It is particularly useful in situations where a JSON object is being deserialized and may take these types of forms:

"https://example.com/id/uuid"
["https://example.com/id/uuid1", "https://example.com/id/uuid2"]
null

These would all match to MaybeMultiple as ::Single, ::Multiple, ::None, respectively.

Dependencies

~2.8–5MB
~88K SLoC