Created
August 20, 2024 11:13
-
-
Save theangryangel/7f5a62e13a1fd7a728149244dadf2c97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mod thing { | |
pub(super) struct Thing { | |
pub(super) name: String, | |
pub(super) indicator: usize, | |
} | |
// ---8<--- ... impl Thing here | |
static THANGS: [Thing; 3] = [ | |
Thing::new(1, 'Thing 1'), | |
Thing::new(2, 'Thing 2'), | |
Thing::new(3, 'Thing 3'), | |
]; | |
pub(super) fn get(c: usize) -> Option<&'static Thing> { | |
THANGS.iter().find(|&r| r.indicator == c) | |
} | |
pub(super) fn iter() -> impl Iterator<Item = &'static Thing> { | |
THANGS.iter() | |
} | |
// etc.. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment