Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

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

3 child tags

Use this tag for questions about code written in Rust.

This tag doesn't have a detailed wiki yet.

57%
+2 −1
Q&A Proper location of docstring on struct with attributes

When documenting a struct with attributes, where does the docstring go? Before or after the attribute(s)? Option 1: /// Does it go here? #[derive(Deserialize, Debug)] pub struct Metadata { ...

1 answer  ·  posted 2mo ago by qohelet‭  ·  last activity 2mo ago by qohelet‭

Question rust docstrings
75%
+4 −0
Q&A How to pass command line arguments when using cargo run?

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...

1 answer  ·  posted 7mo ago by Iizuki‭  ·  edited 2mo ago by Alexei‭

Question rust rust-cargo
77%
+5 −0
Q&A Why does this work? .collect() automatic conversion to function return type

I'm completing the rustlings exercises as part of self-teaching Rust. While working on the third iterators exercise, I solved the exercise but don't quite understand why my solution works. Specifi...

1 answer  ·  posted 2mo ago by qohelet‭  ·  last activity 2mo ago by Iizuki‭

Question rust
81%
+7 −0
Q&A What is the purpose of grouping the tests in a `tests` module and is it possible to split them?

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...

3 answers  ·  posted 1y ago by ShadowsRanger‭  ·  last activity 9mo ago by Moshi‭

Question rust testing
71%
+3 −0
Q&A How do I serialize a const generic length array with Serde?

I have the following code: use serde::{Deserialize, Serialize}; #[derive(Sereialize, Deserialize)] struct Container<const SIZE: usize> { contents: [String; SIZE] } But I'm getti...

0 answers  ·  posted 9mo ago by mousetail‭

Question rust serde
75%
+4 −0
Code Reviews Writing a testable console program

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...

2 answers  ·  posted 11mo ago by KevinG‭  ·  last activity 10mo ago by LAFK‭

Question rust
70%
+5 −1
Q&A Read all data from TCP stream in Rust

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...

1 answer  ·  posted 12mo ago by Matthias Braun‭  ·  edited 12mo ago by Matthias Braun‭

Question rust tcp
71%
+3 −0
Q&A How to correctly daemonize a Rocket-based app?

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...

1 answer  ·  posted 2y ago by ghost-in-the-zsh‭  ·  last activity 1y ago by ghost-in-the-zsh‭

Question rust rocket daemon
83%
+8 −0
Q&A What allows a string slice (&str) to outlive its scope?

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 ...

2 answers  ·  posted 2y ago by deleted user  ·  last activity 2y ago by Moshi‭

80%
+6 −0
Q&A Why is this symlink() call returning successfully while apparently failing to create the sym-link?

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...

1 answer  ·  posted 3y ago by ghost-in-the-zsh‭  ·  last activity 2y ago by ghost-in-the-zsh‭

Question rust linux
50%
+1 −1
Q&A Nannou model requires a function pointer: How to return a function pointer

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...

0 answers  ·  posted 2y ago by telefza‭  ·  edited 2y ago by Alexei‭

80%
+6 −0
Q&A error[E0507]: cannot move out of X which is behind a shared reference.

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) ...

1 answer  ·  posted 3y ago by telefza‭  ·  last activity 2y ago by telefza‭

Question rust nannou
77%
+5 −0
Q&A updating a function within a struct

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 { ...

1 answer  ·  posted 3y ago by telefza‭  ·  last activity 3y ago by Derek Elkins‭

Question rust lifetime
80%
+6 −0
Q&A Strange change of object lightness and colour in Nannou application

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 ...

1 answer  ·  posted 3y ago by telefza‭  ·  last activity 3y ago by telefza‭

Question rust nannou
77%
+5 −0
Q&A Handling JSON files in Rust without manually creating mapping classes

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...

1 answer  ·  posted 3y ago by dustytrash‭  ·  last activity 3y ago by r~~‭

Question rust json
80%
+6 −0
Q&A Are generic enums completely abstract?

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) { ...

1 answer  ·  posted 3y ago by jla‭  ·  last activity 3y ago by Derek Elkins‭

Question rust enum
83%
+8 −0
Q&A How can I define a method on [&mut T] where T: MyTrait?

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: ...

1 answer  ·  posted 3y ago by wizzwizz4‭  ·  last activity 3y ago by r~~‭