macro_rules! selector_str {
    ($sel:ident) => { ... };
    ($($sel:ident :)*) => { ... };
    ($sel:expr) => { ... };
    ($($sel:tt)+) => { ... };
}
Expand description

Creates a &'static str from a selector literal, that may be used as the basis of a Sel.

Feature Flag

This macro is defined in objc, which requires the objc feature flag.

Examples

This macro accepts anything that can go in Objective-C’s @selector:

use fruity::selector_str;

assert_eq!(selector_str!(init), "init\0");

assert_eq!(selector_str!(initWithArg:),   "initWithArg:\0");
assert_eq!(selector_str!(initWithArg : ), "initWithArg:\0");

assert_eq!(selector_str!(initWithArg:arg2:),     "initWithArg:arg2:\0");
assert_eq!(selector_str!(initWithArg : arg2 : ), "initWithArg:arg2:\0");

The result of the macro can even be used in a const:

const Sel: &str = selector_str!(initWithArg:);

Invalid selectors will fail to compile:

let sel = selector_str!(initWithArg::);