1#[macro_export]
4macro_rules! dict {
5 () => {{
6 ::nvim_oxi::Dictionary::default()
7 }};
8 ( $( $key:tt : $value:expr ),+ $(,)? ) => {{
9 let mut map: ::std::collections::BTreeMap<
10 ::std::borrow::Cow<'static, str>,
11 ::nvim_oxi::Object
12 > = ::std::collections::BTreeMap::new();
13 $(
14 let k: ::std::borrow::Cow<'static, str> = $crate::__dict_key_to_cow!($key);
15 let v: ::nvim_oxi::Object = ::nvim_oxi::Object::from($value);
16 map.insert(k, v);
17 )+
18 ::nvim_oxi::Dictionary::from_iter(map)
19 }};
20}
21
22#[doc(hidden)]
23#[macro_export]
24macro_rules! __dict_key_to_cow {
25 ($k:literal) => {
26 ::std::borrow::Cow::Borrowed($k)
27 };
28 ($k:ident) => {
29 ::std::borrow::Cow::Borrowed(::std::stringify!($k))
30 };
31 ($k:expr) => {
32 ::std::borrow::Cow::Owned(::std::convert::Into::<::std::string::String>::into($k))
33 };
34}
35
36#[macro_export]
37macro_rules! fn_from {
38 ($path:path) => {
39 ::nvim_oxi::Object::from(::nvim_oxi::Function::from_fn($path))
40 };
41 ($($tokens:tt)+) => {
42 ::nvim_oxi::Object::from(::nvim_oxi::Function::from_fn($($tokens)+))
43 };
44}