Category "rust"

Closing a PostgreSQL Client Connection in Rust

I am new to Rust and I am using the Postgres crate. I am trying to create a wrapper around the PostgreSQL client, and I have defined this Struct: pub struct Pos

The concept of rust lifetime

Question I usually use c++ lang, and recently I'm learning rust lang but now confusing the concept of lifetime. My understanding for lifetime is as follows. Is

VSCode says "Failed to run custom build command" on cbindgen, but it actually works

I have a Rust (2021) lib. It compiled fine. I added a build.rs file with this in it: extern crate cbindgen; use std::env; fn main() { let crate_dir = env:

Unable to execute "trunk serve"

I was getting into Rust and looking at these simple instructions for Yew framework (a frontend framework for Rust). (Found at: https://yew.rs/docs/tutorial) I f

"Cannot borrow `*arr` as immutable because it is also borrowed as mutable" in a function call

Please someone explain the code below and how can it be unsafe and why is borrowchecker complaining here? I am very new to rust and I come from a little bit of

Cosmwasm environment setup error: "first path segment in URL cannot contain colon"

I'm trying to go through the Cosmwasm docs and I'm stuck on the "Setting Up Environment" step. I'm on Ubuntu so when I put the parameters under #bash in my .bas

Lifetime reference among struct data fields

I have the following code which will throw me this error. Basically I want C to reference B which has reference to A. How can I achieve this in Rust? Is it poss

I tried to get the user input and then compare it to somthing and i got a problem [duplicate]

I tried to get the user input and then compare it to somthing and i got a problem :( this is my code: use std::io::stdin; fn main() { let

Filter NFT's in wallet by metaplex candy machine id

Is there any way to filter a users wallet by metaplex candy machine id? I know how to get all of a users nfts via getParsedTokenAccountsByOwner. const tokens =

Read DHT22 with Rust on HiFive1 rev b

Im trying to read my DHT22 weather and humidity sensor on HiFive1 rev b board, but it doesn't want to respond. I connected data line with 10k resistor to 5V Vcc

Return Result<Box<dyn Trait>> in a match

I have a set of types that implements a given trait, I want to get a concrete type object from a string name, strangely it works when my match returns Box<dy

Why doesn't BroadcastStream implement stream

I'm writing an HTTP server in the actix_web framework using the tokio runtime and tokio-stream utilities. I would like to send some data (actix::web::Bytes) fro

Are string literals immutable

I am following the Rust book to learn Rust and currently learning about ownership. Here it mentions, We’ve already seen string literals, where a string v

Associated type for ndarray arguments in rust

I want to create an interface for a (numeric) algorithm for which I want to provide an implementation with ndarray and similar libraries (let's say pytorch bind

Clap raw bytes arguments

I would like to use raw byte argument with clap For example --raw $(echo -n -e 'B\x10CC\x01\xff') will give me the following bytes array [66, 16, 67, 67, 1, 239

Rust application using GTK3 compiles without errors but run give error msg

I have a small application that if I do a println!("Hello World"); compiles and runs properly. If I change the source to ... let app = Application::bui

How to transfer SOL in anchor smart contract instruction

I am creating a dapp where multiple users can deposit SOL into an event account, and depending on whoever wins the event, they can redeem SOL back to their wall

Different behaviors between C and Rust code snippets

I have a C code snippet which uses pipe() and fork() to communicate between parent and child process. I want to replicate it in Rust. For the POSIX APIs used in

Syntax highlighting in egui Rust

I'm writing a text editor in Rust using egui. I am trying to implement syntax highlighting, so I followed the example in the demo. It works there, so I thought

Why doesn't rustc infer the type based on std trait implementations?

Consider the following code: use std::net::IpAddr; pub struct Server { host: IpAddr } impl Server { fn new(host: IpAddr) -> Self { Self {ho