Initially copy/pasted from Add a formatting specifier to limit the max length displayed of collections · Issue #906 · rust-lang/libs-team · GitHub, but with some minor changes. Sometimes, collections get super long, and all that really matters is…
I've made a benchmark of the Rust overhead that can be caused by vtable calls. The reality, however, is that Rust can often do a good job of devirtualizing such calls. This benchmark shows an extreme scenario where devirtualization fails. Static vs…
I’m currently trying to write a Python program. The Python program that I’m working on seems to work fine on Linux, but it sometimes breaks when I run it on Windows. Specifically, it breaks breaks because it sometimes tries to create new directories…
I have a trait with optional behavior, and I'm trying to figure out how to use it behind a trait object. trait Trait { fn required_behavior(&self); fn optional_behavior(&self) where Self: Optional; } trait Optional: Trait {} Unfortunately, this…
Hello, this is my first forum post. I've been reading through the rust book and trying to work on some basic implementations of linear algebra stuff in rust and came across this code that doesn't compile fn main() { let a: [usize; 1]; a[0] = 2;…
Does anyone know some books about how to program Bevy? I don't want to read source code, it's so difficult and I'll go bananas 2 posts - 2 participants Read full topic
I was experimenting with the async_trait crate and stumble upon the following error: future created by async block is not Send by the following code: #[async_trait::async_trait] trait DatabaseManagerGetConnection { async fn get_connection(&self) ->…
I'm new to Rust, and I am trying to understand dyn object lifetimes when inside a Box or NonNull. My goal is to write an adapter for a C API. I have a few C struct types: #[repr(C)] struct ConcreteA { // generated by bindgen } #[repr(C)] struct…
Hi rustaceans! I wanted to build an arena allocator as a little exercise for myself and I came up with this: use std::{alloc::{Layout, alloc, dealloc, handle_alloc_error}, ptr::NonNull}; use std::cell::Cell; pub struct Arena { ptr:…
I'm trying to understand #![feature(specialization)] vs. #![feature(min_specialization)] to inform the design of my types, but I haven't been able to find any novice-accessible documentation. How do the two differ? Specifically, I expected the…
Hey all, I usually use vim as my code editor. Is there a way to easily make cargo build output a list of files that have errors so that I can just feed it into another CLI program? I am not seeing anything obvious in cargo build --help. As an…