Skip to main content

distribute_option

Function distribute_option 

Source
pub fn distribute_option(
    option_value: &str,
    stack_depth: usize,
    option_name: &str,
) -> Result<Vec<Option<String>>, String>
Expand description

Distribute a single option value across all isolation levels.

If the value is a sequence, validates length matches stack depth. If the value is a single value, replicates it for all levels.

Returns an error string if sequence length doesn’t match stack depth.

§Examples

use start_command::sequence_parser::distribute_option;
// Single value replicated
assert_eq!(distribute_option("node:20", 3, "image"), Ok(vec![
    Some("node:20".to_string()),
    Some("node:20".to_string()),
    Some("node:20".to_string()),
]));
// Sequence distributed
assert_eq!(distribute_option("_ user@host _", 3, "endpoint"), Ok(vec![
    None, Some("user@host".to_string()), None,
]));