pub const HARNESS_TEMPLATE: &str = r#"use serde_json::Value;
{user_code}
fn main() {
let input: Value = serde_json::from_reader(std::io::stdin()).unwrap_or(Value::Null);
let output = run(input);
println!("{}", serde_json::to_string(&output).unwrap());
}
"#;Expand description
The harness template that wraps user code.
The user provides fn run(input: serde_json::Value) -> serde_json::Value.
The harness reads JSON from stdin, calls run(), and prints JSON to stdout.
§Available to User Code
serde_json::Value(imported at top level)- All public items from
serde_json(e.g.,serde_json::json!,serde_json::Map) - The full Rust standard library
§Not Available
- External crates other than
serde_json fn main()(provided by the harness)- Crate-level attributes (
#![...]) - Multi-file modules