Category "rust"

Rust actix-web middleware modifying request data

Is there a recommended way of modifying the request received on actix-web. Is there an example on how to modify I am looking for way to add data to the request

Is it possible to print in the same line from right to left in Crossterm

I try to print a couple of words from right to left but my last word overwrite previous and erase line to the end. I got in my output just Second word, What I'm

How to fix Rust diesel cli link libpq.lib error on install

I'm trying (for hours now) to install the cargo crate diesel_cli for postgres. However, every time I run the recommended cargo command: cargo install diesel_cli

OpenGL texture arrays render the texture completely black

I'm attempting to render a .png image as a texture. However, all that is being rendered is a black square. Can anybody see any mistakes in my OpenGL GL_TEXTU

How to reuse Tokio runtime in Rust FFI library

I want to write a FFI wrapper for sn_api library, which contains async functions. It will be used in single-threaded non-async code written in Red. I found, tha

How to call contract's method from crate

I need to call the contract's method from my Indexer. Now I use tokio::process and near-cli written on NodeJs. It looks soundless, and I would like to do that f

Perform checks on a nested enum

I have an enum which is defined as follows: enum MyEnum { X(u32), Y(Vec<MyEnum>), Z(Vec<MyEnum>), } As you can see, the enum is nested

How to iterate over a vector without moving it

I have a recursive type which doesn't implement copy struct Node { board: Board, children: Option<Vec<Node>>, } I have a Vector of these no

Using clap 3 derive macros, how do I specify that at least one argument of a group must be present?

I have a clap struct as follows: #[derive(Clap)] #[clap( version = "0.1.0", author = "..." )] pub struct Cli { #[clap(long)] arg_a: Option<St

How can I deserialize a type where all the fields are default values as a None instead?

I have to deserialize JSON blobs where in some places the absence of an entire object is encoded as an object with the same structure but all of its fields set

Tauri: display webview + svelte overlay or webview all the way with webhooks?

In my desktop app, I want to display a website using tauri. I also want my app to communicate with a local webserver. With tauri, I need to have wry host the we

Tauri: display webview + svelte overlay or webview all the way with webhooks?

In my desktop app, I want to display a website using tauri. I also want my app to communicate with a local webserver. With tauri, I need to have wry host the we

Anchor build error versions of anchor-spl and anchor-lang

I'm using the following repository of rust: https://github.com/SmartCodeBlockchainDev/Nelson-NFT-stacking when I try to do an anchor build I get the following e

How to use the mold linker with cargo?

I'm using lld as my linker currently for Rust, but recently encountered the mold project, which is faster than lld. I'd like to try it for Rust compilation, but

Getting a windows-rs HWND from winit?

I'm fairly new to Rust and am trying to get the following to work: let hwnd : *mut HWND = window.hwnd().cast(); let swapchain = unsafe { factory.CreateSwapCha

How to parse a function with a declarative macro?

I need a declarative macro to parse a function. I wrote one: macro_rules! parse_fn { () => {}; ( $( #[ $Meta : meta ] )* $( pub )? fn $Name

How can I fix the error E0277: the trait bound `[usize]: std::marker::Sized` is not satisfied?

I'm trying to pass an array to a function: fn my_func(xs: [usize]) -> usize { 0 } fn main() { let arr = [329, 457, 657]; let res = my_func(inp)

What happens when you clone a `&str`?

What happens when you clone a &str? Is the cloned &str pointing to the same place as clonee &str or is it something? Is this documented anywhere?

Lifetime of a reference passed to async callback

I have async function to which I am passing async callback. The callback takes a reference as a parameter. use core::future::Future; async fn foo(bar: &u32

Lifetime sub-typing and impl-trait

I bumped into an interesting form of lifetime sub-typing, which I think is valid, but the compiler is skeptical of. Consider the following function, which compu