Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[macro_export]
- macro_rules! create_set_flag_method {
- ($method:ident, $flag:expr, $platforms:expr) => (
- #[cfg(platforms)]
- pub fn $method(enabled: bool) -> Result<(), ()> {
- if enabled {
- self.flags = self.flags | flag;
- } else {
- self.flags = self.flags & !flag;
- }
- Ok(())
- }
- #[cfg(not(platforms))]
- pub fn $method(_enabled: bool) -> Result<(), ()> {
- Err(())
- }
- )
- }
- // ...
- create_set_flag_method!(
- set_nonblocking,
- MSG_DONTWAIT,
- any(target_os = "freebsd", target_os = "linux")
- );
- // make fails with following error:
- error[E0428]: a value named `set_nonblocking` has already been defined in this module
- --> src/transport.rs:217:9
- |
- 217 | pub fn $method(_enabled: bool) -> Result<(), ()> {
- | _________-
- | |_________|
- | ||
- 218 | || Err(())
- 219 | || }
- | || -
- | ||_________|
- | |__________`set_nonblocking` already defined
- | previous definition of `set_nonblocking` here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement