From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../uniffi-fixtures/callbacks/src/lib.rs | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 toolkit/components/uniffi-fixtures/callbacks/src/lib.rs (limited to 'toolkit/components/uniffi-fixtures/callbacks/src/lib.rs') diff --git a/toolkit/components/uniffi-fixtures/callbacks/src/lib.rs b/toolkit/components/uniffi-fixtures/callbacks/src/lib.rs new file mode 100644 index 0000000000..9ada66bca5 --- /dev/null +++ b/toolkit/components/uniffi-fixtures/callbacks/src/lib.rs @@ -0,0 +1,23 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +trait Logger { + fn log(&self, message: String); + fn finished(&self); +} + +fn log_even_numbers(logger: Box, items: Vec) { + for i in items { + if i % 2 == 0 { + logger.log(format!("Saw even number: {i}")) + } + } + logger.finished(); +} + +fn log_even_numbers_main_thread(logger: Box, items: Vec) { + log_even_numbers(logger, items) +} + +include!(concat!(env!("OUT_DIR"), "/callbacks.uniffi.rs")); -- cgit v1.2.3