Created
November 22, 2021 23:53
-
-
Save danii/9827e1261ebff984fd9145870b4cb165 to your computer and use it in GitHub Desktop.
iter! Macro
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
use std::iter::{empty, once}; | |
macro_rules! iter { | |
() => {empty()}; | |
($first:expr $(, $($rest:expr),*)?) => { | |
once($first).chain(iter![$($($rest),*)?]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment