From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/elasticlunr-rs/examples/export_json.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 vendor/elasticlunr-rs/examples/export_json.rs (limited to 'vendor/elasticlunr-rs/examples') diff --git a/vendor/elasticlunr-rs/examples/export_json.rs b/vendor/elasticlunr-rs/examples/export_json.rs new file mode 100644 index 000000000..3e70a4de0 --- /dev/null +++ b/vendor/elasticlunr-rs/examples/export_json.rs @@ -0,0 +1,23 @@ +use elasticlunr::Index; +use std::fs::File; +use std::io::Write; + +fn main() { + let mut index = Index::new(&["title", "body"]); + index.add_doc( + "1", + &[ + "This Week in Rust 207", + "Hello and welcome to another issue of This Week in Rust!", + ], + ); + index.add_doc( + "2", + &[ + "This Week in Rust 206", + "Hello and welcome to another issue of This Week in Rust!", + ], + ); + let mut file = File::create("examples/out.json").unwrap(); + file.write_all(index.to_json_pretty().as_bytes()).unwrap(); +} -- cgit v1.2.3