diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /toolkit/components/uniffi-fixtures/callbacks/src/lib.rs | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/uniffi-fixtures/callbacks/src/lib.rs')
-rw-r--r-- | toolkit/components/uniffi-fixtures/callbacks/src/lib.rs | 23 |
1 files changed, 23 insertions, 0 deletions
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<dyn Logger>, items: Vec<i32>) { + 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<dyn Logger>, items: Vec<i32>) { + log_even_numbers(logger, items) +} + +include!(concat!(env!("OUT_DIR"), "/callbacks.uniffi.rs")); |