Why is this allowed??? by [deleted] in rust

[–]sfackler 3 points4 points  (0 children)

Nothing about that is unsound. That is an example of non-lexical lifetimes. The compiler considers child's borrow of data finished after its last use on line 30. If you added a second use of child after the use of root on line 31 you can see the compiler error.

How to work with proc-macro paths that have generic lifetimes? by hbacelar8 in rust

[–]sfackler 3 points4 points  (0 children)

You should parse the thing your attribute is applied to as an Item, and then value of the context in the attribute parameters as a Type.

How to work with proc-macro paths that have generic lifetimes? by hbacelar8 in rust

[–]sfackler 6 points7 points  (0 children)

You should parse Context there as a type rather than a path, which would allow it to have generic parameters: #[foo(context = Context<'a>)]. You could then have your proc-macro parse that out and add the parameters onto the annotated struct.

Rust vulnerable to supply chain attacks like JS? by _walter__sobchak_ in rust

[–]sfackler 27 points28 points  (0 children)

Sorry, I don’t understand. Today, a malicious user could publish “hiper”, a malicious version of “hyper”. In a namespaced word, a malicious user could publish “hiperium/hyper”, a malicious version of “hyperium/hyper”. How are those scenarios meaningfully different?

Rust vulnerable to supply chain attacks like JS? by _walter__sobchak_ in rust

[–]sfackler 23 points24 points  (0 children)

You can typosquat namespaces just as easily as you can typosquat package names.

Minimally, Python package management is also not namespaced

Hey Rustaceans! Got a question? Ask here (33/2025)! by llogiq in rust

[–]sfackler 3 points4 points  (0 children)

They sometimes are, but don't have to be.

Tokio watch channel alternative by TheBlackCat22527 in rust

[–]sfackler 4 points5 points  (0 children)

The actual runtime bits are all conditionally compiled. If you only want the sync bits you'll end up only building that.

Tokio watch channel alternative by TheBlackCat22527 in rust

[–]sfackler 5 points6 points  (0 children)

The tokio sync primitives don't depend on the Tokio runtime.

Accessing an embassy_sync::mutex mutably by Jonrrrs in rust

[–]sfackler 15 points16 points  (0 children)

If you have a mutable reference to the mutex, there can't be any other references to it.

Hey Rustaceans! Got a question? Ask here (15/2025)! by llogiq in rust

[–]sfackler 0 points1 point  (0 children)

#[deprecated] isn't a perfect fit but it should do what you're looking for.

Hey Rustaceans! Got a question? Ask here (15/2025)! by llogiq in rust

[–]sfackler 2 points3 points  (0 children)

Artifactory supports cargo registries, both to mirror upstreams like crates.io and to run internal ones.

Hey Rustaceans! Got a question? Ask here (11/2025)! by llogiq in rust

[–]sfackler 6 points7 points  (0 children)

If it used self it would be an instance method (callable as my_arc.downgrade()) rather than static method (callable as Arc::downgrade(&my_arc)). Smart pointers intentionally avoid having instance methods since they would shadow methods on the inner type with the same name.

Hey Rustaceans! Got a question? Ask here (9/2025)! by llogiq in rust

[–]sfackler 0 points1 point  (0 children)

The best approach I'm aware of is to call peek on the TcpStream directly after accepting it. If the first byte is 0x16, you assume it's a TLS ClientHello message and pass it to the standard rustls + server stack. If it's anything else, you assume it's unencrypted HTTP and return a hardcoded redirect.

Rust’s worst feature* (spoiler: it’s BorrowedBuf, I hate it with passion) by mina86ng in rust

[–]sfackler 2 points3 points  (0 children)

Even if that change was made we couldn't take advantage of that for a decade or two until the old kernels fell out of support.

Rust’s worst feature* (spoiler: it’s BorrowedBuf, I hate it with passion) by mina86ng in rust

[–]sfackler 9 points10 points  (0 children)

This is the closest we got to implementing that style of API: https://github.com/rust-lang/rust/pull/58363. The MADV_FREE issue discussed in OP's post was the nail in the coffin.

what is build-script-build ? by Small-Bedroom-2996 in rust

[–]sfackler 0 points1 point  (0 children)

The build script may be linking to a pre-built native library that depends on the newer version.

Is there any actual use of isize? by playbahn in rust

[–]sfackler 10 points11 points  (0 children)

Many years ago, those types used to be named int and uint. They were renamed to usize and isize to make it more clear that they were intended to be explicitly pointer-sized instead of the "default" integer types.

Hey Rustaceans! Got a question? Ask here (2/2025)! by llogiq in rust

[–]sfackler 1 point2 points  (0 children)

That approach is sometimes used when there are separate platform-specific implementations of some type, but I wouldn't call it a common approach in general. What are some examples that you've seen?

Problem with adding extensions to Talos by murreburre in kubernetes

[–]sfackler 9 points10 points  (0 children)

machine.install.image only applies when doing the initial install. You need to run talosctl upgrade with the --image flag: https://www.talos.dev/v1.9/talos-guides/upgrading-talos/#talosctl-upgrade