I keep getting problems with lifetimes when I use a trait, but not when I directly use a type that implements the trait. I have recreated the problem in a few lines of code, with the inferred types shown. struct Token<'src> { slice: &'src str, } fn…
Why can't I get address in the while loop? struct Foo { elem1: u32, elem2: String, } fn demo1(x: &mut Foo) { let ref_1 = &mut x.elem1; let ref_2 = &mut x.elem2; let ptr_x = x as *mut Foo; // Ok! } fn demo2(x: &mut Foo) { let ref_1 = &mut x.elem1;…
Should I use a alternative to .cmp(), if so what would be the appropiate tool. I can't seem to figure this out. Code (click for more details) Compiler output (click for more details) 8 posts - 3 participants Read full topic
I've recently found myself creating a library which includes some platform-specific ffi usage as well as some much higher-level functionality, which I'd really rather not split into 2 crates. This means I cannot #![forbid(unsafe)] at the top level,…
Is there a good reason for the following code to not compile, or is it just a limitation of the borrow checker? And if it is a limit of the borrow checker, is it feasible to un-limit it at some point or should i rely on unsafe blocks? fn main() {…
I have a trait (we'll call it WrapFn) that is being implemented for all functions whose parameters satisfy FromValue<'a> and return types satisfy IntoValue<'a>. The point of this trait is to convert a function with complex types, e.g. // using…
Recently cargo-lints were stabilized. How do I configure these lints to do the same equivalent of cargo clippy -- -Dwarnings for my CI run? I have checked the lints reference which seems to list all existing lints, and the manifest docs on how to…
I wonder if the following code is sound: use core::mem::transmute; #[derive(Debug)] #[repr(u8)] enum MyEnum { A, B, C, } const { assert!(size_of::<Option<MyEnum>>() == 1) } let a = Some(MyEnum::B); // SAFETY: ??? let t: u8 = unsafe { transmute(a) };…
I'm trying to wrap an external generic API, which has a FromRepresentation trait implemented for most primitive types[1]. I'd like to add a way for this wrapper to collect items from this API into a collection. My first idea was "well, every…
I'm trying to provide a workaround for known-badly-performing Rust versions by using feature(link_llvm_intrinsics) (permitted via RUSTC_BOOTSTRAP on stable compiler builds) but only if a Cargo feature is enabled and only on x86 and x86_64. That is,…
Ref: rend3-hp/rend3/src/util/scatter_copy.rs at 5480169a3dad0092b8b8da18429358177f3a0470 · John-Nagle/rend3-hp · GitHub I'm trying to update rend3-hp (my fork of abandoned rend3) to wgpu 30, from wgpu 24. There were many breaking changes. I'm down…
why rust? not meant to be an antagonistic question. i’ve personally been messing around with both rust and zig on side projects i’d otherwise use c on what has rust actually changed about the way you write systems code? generally, is there anything…
So I've been trying to install macrdp, which seems to be built in Rust, on an Intel iMac. The project was last updated 6 months ago, so it can't be that out-of-date. And the iMac I'm trying to use, while older, is running Sequoia, which isn't that…
Someone on peerlist mentioned that he created a web app in Rust "Frontend is Leptos and backend is Axum, full stack Rust" - I've been in web development for over 2 decades now - What's so new and shiny in this Rust framework ? How are things…