Function percent_encoding::percent_encode [−][src]
pub fn percent_encode<'a>(
input: &'a [u8],
ascii_set: &'static AsciiSet
) -> PercentEncode<'a>ⓘNotable traits for PercentEncode<'a>
impl<'a> Iterator for PercentEncode<'a> type Item = &'a str;
Percent-encode the given bytes with the given set.
Non-ASCII bytes and bytes in ascii_set
are encoded.
The return type:
- Implements
Iterator<Item = &str>
and therefore has a.collect::<String>()
method, - Implements
Display
and therefore has a.to_string()
method, - Implements
Into<Cow<str>>
borrowinginput
when none of its bytes are encoded.
Examples
use percent_encoding::{percent_encode, NON_ALPHANUMERIC}; assert_eq!(percent_encode(b"foo bar?", NON_ALPHANUMERIC).to_string(), "foo%20bar%3F");