]> saetta.ns0.it Git - rust/zakform/commitdiff
Output of a "complete" rust file.
authorAndrea Zagli <azagli@libero.it>
Sat, 20 Jan 2024 09:03:55 +0000 (10:03 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 20 Jan 2024 09:03:55 +0000 (10:03 +0100)
src/bin/c2rs.rs

index 5d05356d5ceed8472a25cccf44c8a54e361f1e13..1e586f9d5d92df8c8b723d28e4e2e446f282566d 100644 (file)
@@ -148,6 +148,12 @@ fn main() {
 
        println!("{:?}", form);
 
+       writeln!(output, "use zakform::fields::{{TField, FOption}};");
+       writeln!(output, "");
+
+       writeln!(output, "pub fn get_form() -> zakform::form::Form {{");
+       writeln!(output, "");
+
        writeln!(output, "let mut f = zakform::form::Form::new();");
 
        for e in form.elements {
@@ -250,4 +256,8 @@ fn main() {
 
                writeln!(output, "f.add_field(Box::new(fi);");
        }
+
+       writeln!(output, "");
+       writeln!(output, "f");
+       writeln!(output, "}}");
 }