/// # Panics
///
/// - if `samples.len()` does not match the `sample_count` passed to [Self::new]
/// - if there are `NaN`s in the sample slice
Since this is library code, why not make the function return a Result
?
I thought it’s been a while, but apparently the rate of NOT A CONTRIBUTIONs is up, not down.
start a process within a specific veth
That sentence doesn’t make any sense.
Processes run in network namespaces (netns), and that’s exactly what ip netns exec
does.
A newly created netns via ip netns add
has no network connectivity at all. Even (private) localhost is down and you have to run ip link set lo up
to bring it up.
You use veth
pairs to connect a virtual device in a network namespace, with a virtual device in the default namespace (or another namespace with internet connectivity).
You route the VPN server address via the netns veth device and nothing else. Then you run wireguard/OpenVPN inside netns.
Avoid using systemd since it runs in the default netns by default, even if called from a process running in another netns.
The way I do it is:
ns_con AA
ip netns exec
):ns_run AA <cmd>
export DISPLAY=:0 # for X11
export XDG_RUNTIME_DIR=/run/user/1000 # to connect to already running pipewire...
# double check this is running in AA ns
tmux -f -f <alternative_config_file_if_needed> -L NS_AA
I have this in my tmux config:
set-option -g status-left "[#{b:socket_path}:#I] "
So I always know which socket a tmux session is running on. You can include network info there if you’re still not confident in your setup.
Now, I can detach that tmux session. Reattaching with tmux -L NS_AA attach
from anywhere will give me the session still running in AA
.
You don’t even need full-fledged containers for that btw.
Learn how to script with ip netns
and veth
.
Yes, but then the concrete type of None
literals becomes unknown, which is what I was trying to point out.
The macro rules are all used.
Oops. I was looking at it wrong.
I didn’t make
Option<&str>
an option because the struct is for typeOption<String>
.
Re-read the end of OP’s requirements.
* Two of your macro rules are not used 😉 (expand to see which ones).
Option<&str>
. If it did, we would lose literal None
support 😉A generic impl is impossible.
Imagine you want to turn a Into<String>
to Some(val.into())
and Option<Into<String>>
to val.map(Into::into)
.
Now, what if there is a type T
where impl From <Option<T>> for String
is implemented?
Then we would have a conflict.
If you only need this for &str
and String
, then you can add a wrapper type OptionStringWrapper(Option<String>)
and implement From<T> for OptionStringWrapper
for all concrete type cases you want to support, and go from there.
Good work.
I don’t know if kornel* still lurks here, but I think he did/does related/similar analysis for https://lib.rs.
You could have just mentioned the project in question since its code is public.
https://git.joinplu.me/plume/plume
% git grep '#!\[feature'
plume-common/src/lib.rs:#![feature(associated_type_defaults)]
plume-front/src/lib.rs:#![feature(decl_macro, proc_macro_hygiene)]
plume-models/src/lib.rs:#![feature(never_type)]
plume-models/src/lib.rs:#![feature(proc_macro_hygiene)]
plume-models/src/lib.rs:#![feature(box_patterns)]
src/main.rs:#![feature(decl_macro, proc_macro_hygiene)]
% cat rust-toolchain
nightly-2022-07-19
% rm -f rust-toolchain
% cargo check
No errors from plume crates, but we get errors in a couple of locked dependencies:
error[E0422]: cannot find struct, variant or union type `LineColumn` in crate `proc_macro`
--> /home/user64/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.49/src/wrapper.rs:479:33
|
479 | let proc_macro::LineColumn { line, column } = s.start();
| ^^^^^^^^^^ not found in `proc_macro`
|
help: consider importing one of these items
|
1 + use crate::LineColumn;
|
1 + use crate::fallback::LineColumn;
|
help: if you import `LineColumn`, refer to it directly
|
479 - let proc_macro::LineColumn { line, column } = s.start();
479 + let LineColumn { line, column } = s.start();
|
Compiling generic-array v0.14.6
error[E0422]: cannot find struct, variant or union type `LineColumn` in crate `proc_macro`
--> /home/user64/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.49/src/wrapper.rs:496:33
|
496 | let proc_macro::LineColumn { line, column } = s.end();
| ^^^^^^^^^^ not found in `proc_macro`
|
help: consider importing one of these items
|
1 + use crate::LineColumn;
|
1 + use crate::fallback::LineColumn;
|
help: if you import `LineColumn`, refer to it directly
|
496 - let proc_macro::LineColumn { line, column } = s.end();
496 + let LineColumn { line, column } = s.end();
|
Checking once_cell v1.17.0
error[E0635]: unknown feature `proc_macro_span_shrink`
--> /home/user64/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.49/src/lib.rs:92:30
|
92 | feature(proc_macro_span, proc_macro_span_shrink)
| ^^^^^^^^^^^^^^^^^^^^^^
Let’s see if a full (semver-compatible) deps update works:
% cargo update
% cargo check
This succeeds.
I will let you pick it from here.
Should be a good learning experience.
What unstable features are used by the project you’re trying to fix?
Didn’t read the post yet. But for future reference, posting archived links to posts from that website is probably preferable since it doesn’t appear to be hosted in a way that can handle large traffic.
A good time to refresh my Rust folder as a whole to see what features got stabilized, removed, or subsumed.
My current list of used unstable features is down to 20.
Some lang, some lib.
A couple incomplete.
Some are more important than others.
#![feature(adt_const_params)]
#![feature(async_closure)]
#![feature(const_type_name)]
#![feature(duration_constants)]
#![feature(extract_if)]
#![feature(generic_arg_infer)]
#![feature(impl_trait_in_assoc_type)]
#![feature(iter_array_chunks)]
#![feature(let_chains)]
#![feature(macro_metavar_expr)]
#![feature(map_try_insert)]
#![feature(never_type)]
#![feature(once_cell_try)]
#![feature(proc_macro_hygiene)]
#![feature(specialization)]
#![feature(step_trait)]
#![feature(stmt_expr_attributes)]
#![feature(try_blocks)]
#![feature(try_find)]
#![feature(type_changing_struct_update)]
DISCLAIMER: this is not an endorsement of try_blocks
😐
Maybe I should have written something simpler like “What is the shortest distance between two points, and how does it look like?”
The problem is, if you knew anything about the subject matter, you would know that even JAVA code ends up being compiled ahead-of-time by ART to ELF binaries on Android.
Even non-devs know this stuff!
Yes. That was a part of “1. needed”.
Read about how Dart/Flutter does it.
they were practically in denial that it existed 😅 Some serious java hate.
You seem to imply that this is something 1. needed 2. wanted. 3. somehow threatening. Which is a hilarious thought.
You should have kept this in the microblogtard platform of your choice.
You should have mentioned OP.
@fil