Error "may not be safely transferred across an unwind boundary" when using catch_unwind in Rust

Advertisements I’m testing panic catch features in Rust. I have the following program: use std::panic; fn create_greeting(name: &str) -> String { //panic!("Oh no, something went wrong!"); let greeting = format!("Hello, {}!", name); return greeting; } fn main() { let mut msg: String; let result = panic::catch_unwind(|| { let name = "Alice"; msg = create_greeting(name); });… Read More Error "may not be safely transferred across an unwind boundary" when using catch_unwind in Rust

When I run a certain compiler flag the Rust compiler can't find my main

Advertisements #![cfg(feature = "const_mut_refs")] //currently breaking my main function fn main() { println!("Hello, world!"); } Currently whenever I have this compiler flag on my nightly compiler my main function can’t be found. It gives me the error: "main function not found in crate insert_name_here consider adding a main function to src/main.rs" I don’t know who… Read More When I run a certain compiler flag the Rust compiler can't find my main

How does this closure satisfy the trait bounds when it appears to drop a parameter

Advertisements Hi I am looking over the documentation of asnyc_task and notice that in the example code: use async_task::Runnable; use flume::{Receiver, Sender}; use std::rc::Rc; thread_local! { // A queue that holds scheduled tasks. static QUEUE: (Sender<Runnable>, Receiver<Runnable>) = flume::unbounded(); } // Make a non-Send future. let msg: Rc<str> = "Hello, world!".into(); let future = async… Read More How does this closure satisfy the trait bounds when it appears to drop a parameter

error[E0369]: cannot multiply `f64` by `f64` in Rust

Advertisements I am a Rust learner. I want to make a function that multiplies an euclid::Vector3D<f64,U> by an f64. I have this code: use euclid::Vector3D; fn main() { fn scale_vector<f64,Unit>(vec: Vector3D::<f64, Unit>, scale: f64) -> Vector3D::<f64, Unit> { Vector3D::<f64, Unit>::new(vec.x * scale, vec.y * scale, vec.z * scale) } enum Meters {} let vec =… Read More error[E0369]: cannot multiply `f64` by `f64` in Rust