Skip to main content

extract_style_and_file_arg

Function extract_style_and_file_arg 

Source
pub fn extract_style_and_file_arg(
    args: &[Value],
) -> Result<(Vec<Value>, Option<StyleSpec>, Option<String>), String>
Expand description

Splits off an optional trailing style and/or file-path argument from args.

Processing order (first match wins):

  1. Trailing 'color', <value> named-argument pair.
  2. Trailing 1×3 RGB matrix (values in [0, 1]) — only when the number of remaining data args would exceed min_data after stripping.
  3. Trailing MATLAB-style format string ("r--", "red", "#FF4400", …).
  4. Trailing file path (.svg, .png, or "ascii").

min_data sets the minimum number of data arguments that must remain after removing the style element. Pass 1 for most callers; pass a higher value (e.g. 4 for quiver) to prevent ambiguous vector data from being consumed as an RGB colour spec.

Returns (data_args, style, path).