I'd like to write a custom attribute for a const
field, which will later be accessed throughout my entire library.
Example
// default declaration in `my_lib`...
pub const INITIAL_VEC_CAPACITY: usize = 10;
//...but can be overriden by dependent crates...
#[mylib_initial_vec_capacity]
pub const INITIAL_VEC_CAPACITY: usize = 5;
//...then can be accessed within my crate:
pub fn do_something() {
let mut vec = Vec::with_capacity(macros::INITIAL_VEC_CAPACITY);
/* do stuff with vec */
}
How would I go about achieving this?