Category "rust"

How do I get a *mut c_char from a Str?

To be able to use C library, I need to give a *mut c_char parameter to a function. But I don't find a way to have it from a str. I converted my str to a CStrin

Move struct into a separate file without splitting into a separate module?

I have this file hierarchy: main.rs protocol/ protocol/mod.rs protocol/struct.rs In struct.rs: pub struct Struct { members: i8 } impl Struct { pub

How can I create an is_prime function that is generic over various integer types?

I just took the dive into Rust and want to make some basic math functions that are generic. I have the following is_prime function: fn is_prime(n: i64) -> b

Unable to compile Rust program: LNK1181: cannot open input file 'C:\\Program.obj'

I am getting the error: C:\rust\hello_world\src>where link.exe C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\bin\

Access struct field by variable

I want to iterate over over the fields of a struct and access its respective value for each iteration: #[derive(Default, Debug)] struct A { foo: String,

How do I configure actix-web to accept CORS requests from any origin?

I am building a REST API with actix-web. How do I configure CORS to accept requests from any origin? Cors::new() // <- Construct CORS middleware builder

Alternatives for self-referential structs in Rust?

There are tons of questions about self-referential structs in Rust here, and I think I've read them all, but I'm still having trouble wrapping my head around th

How do I invoke a C++ Arduino library from rust?

It has been possible to build apps for Arduino and Teensy written in Rust for a while. You can find lists of peripheral libraries ( https://github.com/rust-embe

check pointer size at compile time

I found similar question Compile-time generic type size check, but it not received any answer. The problem is in cooperation with other programming language vi

How to display an image in real-time using Rust?

I am trying to write a ray tracer and want to render my image in real time in a GUI window. Basically, I have a buffer: Vec<u8> that is constantly updatin

egui glow image black screen

pub struct FrameBuffer { renderer_id: glow::Framebuffer, color_attachment: glow::Texture, //depth_attachment: glow::Texture, width: u32, hei

Convert glow::Framebuffer to u64

egui::Image::new can take a User(u64) as the first parameter. I have a glow::Framebuffer that I want to pass to the function like egui::Image::new(User(frame_bu

Can I prevent cargo from rebuilding libraries with every new project?

Suppose I execute cargo new one --bin and cargo new two --bin then add the same dependency to each project's Cargo.toml and build them. Now there are two absolu

How to write a function that only accepts one enum variant as input?

I have an enum: enum Group { OfTwo { first: usize, second: usize, }, OfThree { one: usize, two: usize, three

How to write a function that only accepts one enum variant as input?

I have an enum: enum Group { OfTwo { first: usize, second: usize, }, OfThree { one: usize, two: usize, three

How to write a function that only accepts one enum variant as input?

I have an enum: enum Group { OfTwo { first: usize, second: usize, }, OfThree { one: usize, two: usize, three

How to write a function that only accepts one enum variant as input?

I have an enum: enum Group { OfTwo { first: usize, second: usize, }, OfThree { one: usize, two: usize, three