symbols!() { /* proc-macro */ }
Expand description
Defines a list of Symbol
s.
The #[call(path)]
attribute can be used to specify a function to call when
the symbol is invoked. The function must be NativeFunc
.
โ
const EMOJI: &[(&str, Symbol)] = symbols! {
// A plain symbol without modifiers.
abacus: '๐งฎ',
// A symbol with a modifierless default and one modifier.
alien: ['๐ฝ', monster: '๐พ'],
// A symbol where each variant has a modifier. The first one will be
// the default.
clock: [one: '๐', two: '๐', ...],
// A callable symbol without modifiers.
breve: #[call(crate::math::breve)] 'ห',
// A callable symbol with a modifierless default and one modifier.
acute: [
#[call(crate::math::acute)] 'ยด',
double: 'ห',
],
// A callable symbol where each variant has a modifier.
arrow: [
#[call(crate::math::arrow)] r: 'โ',
r.long.bar: 'โผ',
#[call(crate::math::arrow_l)] l: 'โ',
l.long.bar: 'โป',
],
}
Note: While this could use macro_rules!
instead of a proc-macro, it was
horribly slow in rust-analyzer. The underlying cause might be
this issue.