Function url_encoded_data::split_url_encoded_string[][src]

pub fn split_url_encoded_string(s: &str) -> (&str, &str)

split to ‘prefix’ + ‘data_str’

use url_encoded_data::split_url_encoded_string;
let url = "https://google.com/?q=rust";
let (prefix, data_str) = split_url_encoded_string(url);
println!("prefix: {:?}, data_str: {:?}", prefix, data_str);
assert_eq!(prefix, "https://google.com/?");
assert_eq!(data_str, "q=rust");

let s = "";
let (prefix, data_str) = split_url_encoded_string(s);
println!("prefix: {:?}, data_str: {:?}", prefix, data_str);
assert_eq!(prefix, "");
assert_eq!(data_str, "");

let s = "?";
let (prefix, data_str) = split_url_encoded_string(s);
println!("prefix: {:?}, data_str: {:?}", prefix, data_str);
assert_eq!(prefix, "?");
assert_eq!(data_str, "");

let s = "q=rust";
let (prefix, data_str) = split_url_encoded_string(s);
println!("prefix: {:?}, data_str: {:?}", prefix, data_str);
assert_eq!(prefix, "");
assert_eq!(data_str, "q=rust");