Category "rust"

Global function pointer to a method errors "mismatched types"

I want to make a global function pointer pointing to a class method, so I did something like the following minimal reproducible example: struct Foo<'a> {

How to build an Apache Arrow message containing a list of structs with arrow-rs?

I'm using the arrow-rs crate (version 4.4) to declared the following schema: Schema::new(vec![ Field::new("name", DataType::Utf8, false),

Need a dynamic size buffer when listening to a udpsocket

This is the current code listening to the udpsocket at port: 34254 use std::net::UdpSocket; use std::str; fn main() -> std::io::Result<()> { {

egui combobox vector for selected

I am trying to use a vector instead of the enum specified in the docs but I have no clue how to implement the selected part. My current code is egui::ComboBox::

How would i run a Rust program without a window only when it's in release mode [duplicate]

I have a Rust project I'm currently working on and I frequently have to debug and deploy it. While it's deployed it runs in the background wit

Could not find `Cargo.toml` running Cargo in docker container

I am using the code: docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ --mount type=volume,s

How to benchmark memory usage of a function?

I notice that Rust's test has a benchmark mode that will measure execution time in ns/iter, but I could not find a way to measure memory usage. How would I imp

How to send JSON as response in tokio & warp?

I want to post the string into the server and deserialize it and send back JSON object via warp. It works fine with strings but it wont send JSON messages to We

Deserializer never called when field is not present

I have a custom serializer and deserializer. where the a field is of type Option<i32> and turns into stringified "i32" when serializing or skips the field

Why do sender and minter should be same on minting NFT?

I am developing NFT marketplace with terra and I use CW721. And I noticed on mint function if the sender and minter is not equal it returns "Unauthorized" error

How can I convert a buffer of a slice of bytes (&[u8]) to an integer?

I am reading raw data from a file and I want to convert it to an integer: fn main() { let buf: &[u8] = &[0, 0, 0, 1]; let num = slice_to_i8(buf

Generic function that returns different types based on the value of an argument

I have a struct which holds registers. I want my read_register function to return a u8 for Register::V0 and Register::V1 but a u16 for Register::V2 and Register

rustup gives command not found error with zsh even after installing with brew

I installed rustup with brew command but still says that rustup command is not found. I am not sure if I am missing any installation step. Any help would be app

How do I idiomatically convert a bool to an Option or Result in Rust?

It seems there is no way of such one-line conversion using std. I do not like this kind of verbosity: match my_bool { true => Ok(()), false => Err

Pass a pointer string as an argument in host import function in Rust WebAassembly (wasmtime)

so I have the following import in my generated .wast file (disclaimer: I have not written the wasm file myself): (import "index" "bigDecimal.fromString" (func

Rust compilation error " failed to run custom build command for `freetype-sys v0.13.1' " win 10

I am trying to build a Rust program on Windows 10 having a GUI. When trying to compile a Rust file with gtk dependency on Windows 10 I keep getting the followin

How to config payload limit for a actix websocket server

I am learning Actix and try creating a WebSocket service code snippets: starts server pub async fn start(addr: &str) -> std::result::Result<(), IoErro

Why is Rust pushing new line into String when pushing optional character? [duplicate]

I am trying an exercise from the end of Chapter 8 in The Rust Programming Language to translate words into pig latin. Unfortunately, I am hav

How do I write a Rust unit test that ensures that a panic has occurred?

I have a Rust function that panics under some condition and I wish to write a test case to validate whether the function is panicking or not. I couldn't find an

How does one create a HashMap with a default value in Rust?

Being fairly new to Rust, I was wondering on how to create a HashMap with a default value for a key? For example, having a default value 0 for any key inserted