fish-shell/fish-rust/src
Mahmoud Al-Qudsi 455b744bca Port fd_monitor tests to rust
This shows some of the ugliness of the rust borrow checker when it comes to
safely implementing any sort of recursive access and the need to be overly
explicit about which types are actually used across threads and which aren't.

We're forced to use an `Arc` for `ItemMaker` (née `item_maker_t`) because
there's no other way to make it clear that its lifetime will last longer than
the FdMonitor's. But once we've created an `Arc<T>` we can't call
`Arc::get_mut()` to get an `&mut T` once we've created even a single weak
reference to the Arc (because that weak ref could be upgraded to a strong ref at
any time). This means we need to finish configuring any non-atomic properties
(such as `ItemMaker::always_exit`) before we initialize the callback (which
needs an `Arc<ItemMaker>` to do its thing).

Because rust doesn't like self-referential types and because of the fact that we
now need to create both the `ItemMaker` and the `FdMonitorItem` separately
before we set the callback (at which point it becomes impossible to get a
mutable reference to the `ItemMaker`), `ItemMaker::item` is dropped from the
struct and we instead have the "constructor" for `ItemMaker` take a reference to
an `FdMonitor` instance and directly add itself to the monitor's set, meaning we
don't need to move the item out of the `ItemMaker` in order to add it to the
`FdMonitor` set later.
2023-03-05 00:33:53 -06:00
..
builtins Port bg builtin to Rust (#9621) 2023-02-28 16:42:12 -06:00
tests Port fd_monitor tests to rust 2023-03-05 00:33:53 -06:00
wutil Allow using wgettext_fmt without comma from macros 2023-03-04 22:24:22 +01:00
abbrs.rs abbr: port abbreviation and abbr builtin to rust 2023-02-25 12:24:58 +01:00
color.rs Port color.cpp to Rust 2023-03-04 11:46:46 -08:00
common.rs Port read_loop() and write_loop() to rust 2023-03-05 00:22:56 -06:00
env.rs env: port env constants to rust 2023-02-25 12:24:32 +01:00
fd_monitor.rs Make fd_monitor types useable from native code 2023-03-05 00:23:01 -06:00
fd_readable_set.rs Port fd_monitor (and its needed components) 2023-02-19 15:42:03 -06:00
fds.rs Port fd_monitor (and its needed components) 2023-02-19 15:42:03 -06:00
ffi.rs Rewrite wrealpath from wutil in Rust (#9613) 2023-02-26 20:13:40 -07:00
ffi_init.rs Port (and use) ASSERT_IS_BACKGROUND_THREAD/ASSERT_IS_MAIN_THREAD 2023-02-19 16:54:50 -06:00
ffi_tests.rs rust: fix doc comments 2023-02-05 11:57:25 +01:00
flog.rs Improve FLOG output 2023-03-04 11:35:21 -08:00
future_feature_flags.rs Follow Rust naming convention for some types 2023-02-08 21:49:54 +01:00
job_group.rs Run rustfmt and clippy in CI (#9616) 2023-02-26 13:20:20 -06:00
lib.rs Port fd_monitor tests to rust 2023-03-05 00:33:53 -06:00
nix.rs Address clippy lints 2023-02-25 12:24:25 +01:00
parse_constants.rs Implement more bitwise operation for parser bitfields 2023-03-04 22:24:22 +01:00
re.rs re: port regex make anchored to rust and helper ffi funtions for regex 2023-02-25 12:24:57 +01:00
redirection.rs Port redirection.cpp to Rust 2023-02-09 00:37:22 +01:00
signal.rs Port job_group to rust (#9608) 2023-02-25 16:42:45 -06:00
smoke.rs Add an FFI test facility 2023-02-02 19:34:48 -07:00
threads.rs Improve FLOG output 2023-03-04 11:35:21 -08:00
timer.rs Address clippy lints 2023-02-25 12:24:25 +01:00
tokenizer.rs Implement more bitwise operation for parser bitfields 2023-03-04 22:24:22 +01:00
topic_monitor.rs Improve FLOG output 2023-03-04 11:35:21 -08:00
util.rs Prefer taking native Rust strings instead of wcharz_t 2023-02-05 12:22:42 +01:00
wchar.rs Support widestring macro on non-literal strings 2023-03-04 22:24:22 +01:00
wchar_ext.rs rust: fix issues reported by clippy 2023-02-05 11:57:25 +01:00
wchar_ffi.rs Rewrite wrealpath from wutil in Rust (#9613) 2023-02-26 20:13:40 -07:00
wgetopt.rs wgetopt: fix long option match to always match prefix 2023-02-18 18:53:40 +01:00