Category "rust"

How to compose warp log?

I am pretty new in Rust and trying to build a web application with https://docs.rs/warp/0.2.3/warp/index.html. I have tried: #[tokio::main] async fn main()

Why does my string not match when reading user input from stdin?

I'm trying to get user input and check if the user put in "y" or "n". Surprisingly, in the below code, neither the if nor the if else case executes! Apparently,

Rust thrussh library client example fails at channel_open_session

In thrussh's documentation they have server and client example code. Code based on the example server code has been working fine in various projects. However,

How do I print a backtrace without panicking using thiserror?

I am running a Rust warp webserver and I need more descriptive error messages. I'd like to print a backtrace or something similar so I can tell where the error

Why is rust-analyzer not finding dependencies in workspace member?

I have a cargo workspace with one library "./raytracing" and one binary "./cli". The two workspace members have different dependencies. ./raytracing/Cargo.toml:

Debugging Rust on Vscode : u8 not shown correctly

I am debugging this simple Rust program on Vscode fn main() { let u8: u8 = 3; let b: u16 = 5; let c: u32 = 7; let d: u64 = 9; } The values of t

Building rust with LLVM Fork

Following the instructions here, I have tried building rust with a fork of LLVM which has a back-end for a new target. I have: Recursively cloned the Rust repos

Airdropping Solana to a Specific Account

I would like to airdrop sols into a specific account to get my smart contract to fire an anchor test. Whenever I run my test I come across the error Error: Acco

Struct padding rules in Rust

Recently when I was learning Type Layout in Rust, I saw that struct in Rust supports the #[repr(C)] directive, so I want to to see the difference between the de

Rust build error: unknown `--json` option `future-incompat`

I am trying to build a basic application for the Adafruit CLUE using Rust. When using the peripheral access crate (PAC) everything works fine, but I would like

Is allowing library users to embed arbitrary data in your structures a correct usage of std::mem::transmute?

A library I'm working on stores various data structures in a graph-like manner. I'd like to let users store metadata ("annotations") in nodes, so they can retri

Set a project to use nightly by default

How do I set a Cargo project to build & run using nightly by default (i.e. cargo build is actually cargo +nightly build) without setting nightly as the glob

Classifying cubic bezier curves according to Loop & Blinn 2005

I am trying flatten a bezier path (remove all intersections and replace with end points) as part of the implementation of the rendering algori

Conways game of Life with 1D array

Right now I'm doing this tutorial for WebAssembly with Rust. The task is to implement Conways Game of Life in Rust. Writing a low-level language like Rust is ne

How to return the value of a reference field of a struct that is no longer used without copy?

Code like this: pub fn sample_from_categorical_logits(prob_logits: Tensor) -> (Tensor, Tensor) { let prob_obj = match prob_logits.size().len() {

Rust not printing to terminal

rustc is not outputting anything to terminal when using println!. Code: fn main() { println!("Hello, world!"); } Running it: me@mclaptop:~ > rustc he

Rust update mongo document

I'm trying to update my document, if I don't pass a field it is being deleted. my document is { "_id":"27fc47a4-0730-446c-8acd-41aa6e227406", "user_id":"a

How to build the docs.rs documentation of an FFI crate when the native library is not present?

I have a "sys" crate that links statically to a library: Cargo.toml: [package] links = "foo-1.0" build.rs: fn main() { println!("cargo:rustc-link-lib=d

Can't get Rocket's EventStream! to work with borrowed values

This is a pretty specific question related to the Rocket crate. I'm not sure if this is an issue with the crate or if I'm just doing something plain wrong. I'm

Can you deserialize a struct from a map or a string?

Consider this Config struct which contains a vector of Host structs: use serde::Deserialize; use std::net::IpAddr; #[derive(Debug, Deserialize)] struct Config