Macro rspotify::scopes

source ·
macro_rules! scopes {
    ($($key:expr),*) => { ... };
}
Expand description

Create a HashSet from a list of &str to easily create scopes for Token or OAuth.

Example:

use rspotify_macros::scopes;
use std::collections::HashSet;

let with_macro = scopes!("playlist-read-private", "playlist-read-collaborative");
let mut manually = HashSet::new();
manually.insert("playlist-read-private".to_owned());
manually.insert("playlist-read-collaborative".to_owned());
assert_eq!(with_macro, manually);

Note: the scopes! macro also support to split the word by whitespace so the scope can’t contain any whitespace

use rspotify_macros::scopes;
use std::collections::HashSet;

let macro_with_whitespace = scopes!("playlist-read-private playlist-read-collaborative");
let mut manually = HashSet::new();
manually.insert("playlist-read-private".to_owned());
manually.insert("playlist-read-collaborative".to_owned());
assert_eq!(macro_with_whitespace, manually);