1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
extern crate pct_str;
use pct_str::{PctString, URIReserved};
struct CustomEncoder;
impl pct_str::Encoder for CustomEncoder {
fn encode(&self, c: char) -> bool {
URIReserved.encode(c) || c.is_uppercase()
}
}
fn main() -> pct_str::Result<()> {
let pct_string = PctString::encode("Hello World!".chars(), URIReserved);
println!("{}", pct_string.as_str());
let pct_string = PctString::encode("Hello World!".chars(), CustomEncoder);
println!("{}", pct_string.as_str());
Ok(())
}