Join us in building a kind, collaborative learning community via our updatedCode of Conduct.

Questions tagged [rust]

Rust is a language designed for writing highly reliable and fast software in a simple way. It can be used from high-level code down to hardware-specific code, and from big irons to tiny devices.

1
vote
1answer
27 views

It is possible to collect a &mut from an iterator?

I am trying to learn more about ownership. Here is some code that doesn't work because collect doesn't let you get a &mut String:fn search(word: &str, data: &mut Vec<String>) {...
-1
votes
0answers
19 views

Is there a way to make self into a slice? [duplicate]

Is there any way to take self and make it into a slice such as [u8]?
4
votes
2answers
44 views

Why is tuple formatting limited to 12 items in Rust?

I just started a tutorial in Rust and I can't get my head around the limitation of tuple printing:fn main() {// Tuple definitionlet short=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);let ...
1
vote
1answer
18 views

Visual Studio Code errors when debugging Rust with “Missing auto-load debug_gdb_scripts”

I installed flatpak Visual Studio Code on Linux Mint. I'm trying to debug the "Hello world app" from the Rust book in VS Code. src/main.rs:fn main() {println!("Hello, world!");}launch.json:...
2
votes
1answer
39 views

Implementing a non-moving std::ops:Sub

I'm writing a ray-tracer and I want to be able to subtract my 3d vectors:use std::ops::Sub;#[derive(Clone, Debug)]pub struct Vec3 {pub v: [f64; 3],}impl Sub for Vec3 {type Output=...
1
vote
1answer
28 views

How to access functions from the main crate when writing integration tests?

When creating a project with a test like so:cargo init --bin projectnamemkdir projectname/testsecho "extern crate projectname;" > projectname/tests/test.rscd projectname/cargo buildI get ...
-1
votes
2answers
26 views

Why do I get the error “wrong number of type arguments” when I use hyper::Client in my method signature?

I want to get a hyper::Client configured according to the URL scheme. For that, I created a small method:extern crate http; // 0.1.8extern crate hyper; // 0.12.7extern crate hyper_tls; // 0.1.4...
2
votes
1answer
61 views

How to implement prepend for a linked list without needing to assign to a new variable?

Something told me how to implement a linked list:enum List {Cons(u32, Box<List>),Nil,}impl List {fn prepend(self, elem: u32) -> List {Cons(elem, Box::new(self))...
0
votes
1answer
38 views

How can I input binary values to a vector in Rust?

I have programmed a simple ASCII to string converter but I am facing problems in turning it to a binary to string converter.When I try to input binary values I am getting an error and the vector ...
1
vote
1answer
38 views

Lifetime issue iterating over regex captures

I'm attempting to get all non-whitespace characters from a string using regex, but I keep coming back to the same error.extern crate regex; // 1.0.2use regex::Regex;use std::vec::Vec;pub fn ...
3
votes
2answers
83 views

Why does Rust have a “Never” primitive type?

Rust's std::process::exit has the typepub fn exit(code: i32) -> !where ! is the "Never" primitive type. Why does Rust need a special type for this? Compare this with Haskell where the type ...
3
votes
1answer
41 views

Does Rust have bindings for tee(2)?

Does Rust have bindings for tee(2) in std::io or otherwise? And if there are no bindings, how would I get that functionality in a Rust program?
2
votes
0answers
36 views

Compiler continues to count the borrow as mutable when it is actually immutable [duplicate]

Consider this code, ignoring the warnings:fn main() {}pub struct TreeNode {subs: Vec<TreeNode>,}impl TreeNode {pub fn do_something(&mut self) {if let Some(...
0
votes
0answers
65 views

Execute process task fails to execute Rust script in job

I have written a small Rust script for an import job. I added the script execution into the SSIS package through the Execute process task and set the correct working directory. Using the debugger, the ...
6
votes
1answer
83 views

Can a `&str` contain a pointer to program memory in Rust?

Section 4.3 about slices of The Rust Programming Language has this paragraph:String Literals Are SlicesRecall that we talked about string literals being stored inside thebinary. Now that ...

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,