url::define_encode_set! [] [src]

macro_rules! define_encode_set {
    ($(#[$attr: meta])* pub $name: ident = [$base_set: expr] | {$($ch: pat),*}) => { ... };
}

Define a new struct that implements the EncodeSet trait, for use in percent_decode() and related functions.

Parameters are characters to include in the set in addition to those of the base set. See encode sets specification.

Example

#[macro_use] extern crate url;
use url::percent_encoding::{utf8_percent_encode, SIMPLE_ENCODE_SET};
define_encode_set! {
    /// This encode set is used in the URL parser for query strings.
    pub QUERY_ENCODE_SET = [SIMPLE_ENCODE_SET] | {' ', '"', '#', '<', '>'}
}
assert_eq!(utf8_percent_encode("foo bar", QUERY_ENCODE_SET).collect::<String>(), "foo%20bar");