macro_rules! serde_default {
    ($kind:ty) => { ... };
    ($name:ident,$text:literal) => { ... };
    ($name:ident, &[ $($value:expr),* $(,)? ]) => { ... };
}
Expand description

Generates a function for a type provided or a custom default function This is not supposed to be used outside since const generic parameter approach is pretty limited at the moment

§Limitations

Slices are limited to only &'static [u8] and parcing it from JSON using serde_json::from_str`` will not work, only serde_json::from_str`.

§Output

Generates something like

use serde_default_utils::*;

// Generates
// pub const fn default_u8<const V: u8>() -> u8 {
//     V
// }
serde_default!(u8);

// Generates
// pub const fn default_hey() -> &'static ::core::primitive::str {
//     "hey"
// }
serde_default!(hey, "hey");

// !Experimental!
// (not sure if it's even useful, but this allows you to store raw bytes)
// Generates
// pub const fn default_arr() -> &'static [::core::primitive::u8] {
//     &[1,2,3,4,5]
// }
serde_default!(arr, &[1,2,3,4,5]);

assert!(default_u8::<6>() == 6u8);
assert_eq!(default_hey(), "hey");
assert_eq!(default_arr(), &[1,2,3,4,5]);