pub fn format_sobject_path(sobject: &str, id: Option<&str>) -> String {
let mut capacity = 9 + sobject.len(); if let Some(record_id) = id {
capacity += 1 + record_id.len(); }
let mut path = String::with_capacity(capacity);
path.push_str("sobjects/");
path.push_str(sobject);
if let Some(record_id) = id {
path.push('/');
path.push_str(record_id);
}
path
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_format_sobject_path_with_id() {
assert_eq!(
format_sobject_path("Account", Some("001000000000000")),
"sobjects/Account/001000000000000"
);
}
#[test]
fn test_format_sobject_path_without_id() {
assert_eq!(format_sobject_path("Account", None), "sobjects/Account");
}
}