force 0.2.0

Production-ready Salesforce Platform API client with REST and Bulk API 2.0 support
Documentation
//! Common path formatting utilities.

/// Formats a relative SObject path, optionally including an ID.
///
/// If `id` is provided, returns `sobjects/{sobject}/{id}`.
/// If `id` is not provided, returns `sobjects/{sobject}`.
pub fn format_sobject_path(sobject: &str, id: Option<&str>) -> String {
    // ⚡ Bolt: Avoid intermediate format! allocation
    let mut capacity = 9 + sobject.len(); // "sobjects/".len() == 9
    if let Some(record_id) = id {
        capacity += 1 + record_id.len(); // "/" + record_id
    }

    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");
    }
}