Category "rust"

How to mock function on unit test actix web

I have an api service that has 2 layer: api and repository. The api layer is where the request handling and business logic defined, while repository is a databa

How do I have a hidden console when using windows_subsystem?

My goal is to have it so when the executable is just double clicked no console spawns but also have it able to print to the console when the user launches it fr

Rust egui window size and dark mode

I'm tring to make a native gui app using egui. After some time got the hello_world example to compile.Heres the code: use eframe::{epi, egui}; struct MyEguiApp

How do I compile Rust code without linking, i.e. produce object files?

Due to how the LGPL works, compiling Rust code to an object file without linking would be useful to be able to do. However, I cannot find any documentation on h

How to get the body of a Response in actix_web unit test?

I'm building a web API service with Rust and actix_web. I want to test a route and check if the received response body is what I expect. But I'm struggling with

How to get the body of a Response in actix_web unit test?

I'm building a web API service with Rust and actix_web. I want to test a route and check if the received response body is what I expect. But I'm struggling with

How can I create parameterized tests in Rust?

I want to write test cases that depend on parameters. My test case should be executed for each parameter and I want to see whether it succeeds or fails for each

Is there a way to open a desktop app as a "subview" inside a Tauri app?

I am building my first app with Tauri framework. Basically, I would like to open as embedded "subviews" (as for "IFrame", just to be clear), inside the main pag

How can I use a `rustc` crate?

I'm trying to use a rustc crate in my program. #[macro_use] extern crate rustc; extern crate rustc_typeck; extern crate syntax; extern crate syntax_pos; use ru

How do I persist a struct instance across files?

I want to persist the contents of a struct created in one Rust file into a different Rust file. In this minimal reproduction, command line arguments are used to

Why can I push items into a Vec I am iterating over with a while loop, but not with a for loop?

Like the rust code below: the while loop compiles and runs fine, but for iter version does not compile, due to error: error[E0502]: cannot borrow `v` as mutabl

actix_web invalid header provided

I am getting this error running an actix-web based server ERROR actix_http::h1::dispatcher] stream error: Request parse error: Invalid Header provided The hand

Lifetime in impl does not match method in trait

Code Playground (Stable Rust 1.45.0, 2018 edition) No external crates needed for example. type Error = Box<dyn std::error::Error>; type Result<R=()>

How to add a Pubkey to an account containing a vector of Pubkeys in an anchor program

use anchor_lang::prelude::*; use rand::Rng; use solana_program::{declare_id, pubkey::Pubkey}; declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); #[pr

Is it possible to split a vector into groups of 10 with iterators?

I have let my_vec = (0..25).collect::<Vec<_>>() and I would like to split my_vec into iterators of groups of 10: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; [1

How do I find the index of an element in an array, vector or slice?

I need to find an index of an element in a vector of strings. This is what I got so far: fn main() { let test: Vec<String> = vec![ "one".to_s

How do I make my own window frame in egui (eframe) Rust

Here is how I start my app and remove the window frame: let app = RustClicker::default(); let mut native_options = eframe::NativeOptions::default();

How do I "use" or import a local Rust file? [duplicate]

How do I include a file with the full path my_project/src/include_me.rs in main.rs? I've checked the dependencies guide, and all of them appea

How stop auto refresh of egui screen

I have the following menu item fn update(&mut self, ctx: &egui::Context, frame: &epi::Frame) { //let Self { label, value } = self; // Exam

Programmatically create and listen for multiple signals and a ticking interval with tokio

I'm trying to programmatically listen to multiple signals and a ticking interval. To clear things up, here is the code I have currently: use std::time::Duration