Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Posts tagged rust
When developing a rust program you build and run using cargo run. However you cannot just append arguments to that as they will be caught (and likely rejected) by cargo itself. So how to pass argum...
What is the purpose of grouping the tests in a tests module like this #[cfg(test)] mod tests { use super::*; #[test] fn test_function_1() { // test code for function 1 g...
I have the following code: use serde::{Deserialize, Serialize}; #[derive(Sereialize, Deserialize)] struct Container<const SIZE: usize> { contents: [String; SIZE] } But I'm getti...
I have a class Foo that prints something to stdout and I want to be able to write tests for it. So I created a trait to abstract println!, and gave it a prod implementation and a test implementati...
I'd like to write a TCP client in Rust that can receive the entire message sent by a server, but I have no information about the length of a message. I'm aware that TCP doesn't preserve message bo...
Summary I'm refactoring a Rust-based service/daemon to move away from gRPC and use a Rocket-based API instead. I'm also using the daemonize crate to turn the foreground process into a background p...
As a relative newcomer to Rust, I'm trying to understand the behaviour of lifetimes, but I am confused by the following code: let s: &str = "first"; let mut r: &str = s; println!("First ...
Summary I'm building an internal system (hardware simulator, using Rust) to help test some Python-based services that talk to hardware. (The services talk to hardware via TTYs.) To trick the Pytho...
Trying to make a nannou app from the template but with a customizable model() function. The template has this main(): fn main() { nannou::app(model).update(update).run(); } The model t...
Making a Nannou App that draws a line to the screen. My model only contains the window itself and a vector of tuples describing the points and color. Similar to this example(under Drawing Lines) ...
What I want: An object that contains a function that I can update after creation. I created a struct that contains a parameter b and a function(closure?) named Internal_Fn. struct MyThing { ...
Building a Nannou App from their template. I want a circle to slowly fade in color and randomly change color when hitting the boundary of the window. But there is something strange going on when ...
I have JSON that looks something like this: {"id":"n-fsdf-6b6", "name":"JohnSmith", "revisionDate":1591072274000} The JSON data is named CharacterInfo. It comes from a static external URL. The str...
When using Result or Option to get a value, the value is wrapped in a Ok or Some. For example, with pattern matching to get a Result: let var: Json = match serde_json::from_str(&my_string) { ...
I'm trying to make a trait method callable on mutable slices of a type implementing that trait (see main). Rust doesn't like me for it. use core::convert::AsMut; trait A { type B; fn f(m: ...