Function axon_parser::format_func [−][src]
pub fn format_func(axon: &str, desired_width: usize) -> Result<String, Error>
Expand description
If the axon input represents a function, parse it and return a String
which contains formatted code.
The axon
argument to this function should be a string containing the
output of running <some function src>.parseAst.toAxonCode
in SkySpark.
Example
use axon_parser::format_func; let desired_width = 80; let axon = r###"{type:"func", params:[], body:{type:"block", exprs:[{type:"literal", val:"hello world"}]}}"###; let formatted_code = format_func(axon, desired_width).unwrap(); let expected_code = "() => do\n \"hello world\"\nend"; assert_eq!(formatted_code, expected_code);