Rust

6009 readers
5 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

[email protected]

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS
126
21
submitted 5 months ago by fzz to c/rust
 
 

That was a hard long adventure, massive refactoring with bug-fixing 🥵

127
20
Rust Analyzer Changelog #238 (rust-analyzer.github.io)
submitted 5 months ago by snaggen to c/rust
128
 
 

I went to look into the activitypub federation package from Rust and noticed that it does not support JSON-LD. This took me to a search into other libraries, which got me to RDF-based crates. Just thought it was a good idea to share.

129
 
 

Hi rustaceans! What are you working on this week? Did you discover something new, you want to share?

130
28
submitted 5 months ago* (last edited 5 months ago) by [email protected] to c/rust
 
 

Hey,

Is there any way to create a macro that allows a Some<T> or T as input?

It's for creating a Span struct that I'm using:

struct Span {
    line: usize,
    column: usize,
    file_path: Option<String>,
}

...and I have the following macro:

macro_rules! span {
    ($line:expr, $column:expr) => {
        Span {
            line: $line,
            column: $column
            file_path: None,
        }
    };

    ($line:expr, $column:expr, $file_path: expr) => {
        Span {
            line: $line,
            column: $column
            file_path: Some($file_path.to_string()),
        }
    };
}

...which allows me to do this:

let foo = span!(1, 1);
let bar = span!(1, 1, "file.txt");

However, sometimes I don't want to pass in the file path directly but through a variable that is Option. To do this, I always have to match the variable:

let file_path = Some("file.txt");

let foo = match file_path {
    Some(file_path) => span!(1, 1, file_path),
    None => span!(1, 1),
}

Is there a way which allows me to directly use span!(1, 1, file_path) where file_path could be "file.txt", Some("file.txt") or None?

Thanks in advance!

131
78
Announcing Rust 1.79.0 (blog.rust-lang.org)
submitted 5 months ago by snaggen to c/rust
132
133
134
14
rust-analyzer changelog #237 (rust-analyzer.github.io)
submitted 5 months ago by [email protected] to c/rust
135
19
submitted 5 months ago by [email protected] to c/rust
 
 

Morning all!

Okay, let me start out by saying that I know absolutely sweet F.A. about Rust. There's simply something I'm trying to get working and it's required me to make a few changes. And with every change, it's getting closer to building successfully… or so I hope.

Anyway, I'm here to bother you for a reason, not just to waffle. I was wondering if someone could be kind enough to explain this rust toolchain malarkey?

When I started trying to "fix" this thing (it's a dockerfile), I updated it to build from the latest and greatest rust and then updated to the latest and… I digress, point being it's failing some cargo stuff and I have reason to believe it's because of the rust toolchain which is set as nightly-2022-07-19 now, I thought I could just set that to stable, but upon reading some docs, I need to set the date. I was just wondering if someone could explain why? Why can't I just have the toolchain set to latest? It seems complicated for nothing.

136
47
The borrow checker within (smallcultfollowing.com)
submitted 5 months ago by turbohz to c/rust
137
138
25
Rust Analyzer Changelog #235 (rust-analyzer.github.io)
submitted 5 months ago by snaggen to c/rust
139
38
submitted 5 months ago by snaggen to c/rust
140
 
 

Hi rustaceans! What are you working on this week? Did you discover something new, you want to share?

141
29
submitted 6 months ago by snaggen to c/rust
142
 
 

This is my first try at anything open source so any feedback is welcome :)

143
17
Rust Analyzer Changelog #234 (rust-analyzer.github.io)
submitted 6 months ago by snaggen to c/rust
144
 
 

Hi rustaceans! What are you working on this week? Did you discover something new, you want to share?

145
10
Dart Macros (youtu.be)
submitted 6 months ago by FizzyOrange to c/rust
 
 

Very impressive IDE integration for Dart macros. Something to aspire to.

146
21
submitted 6 months ago by snaggen to c/rust
147
 
 

#rust #rustlang

148
10
submitted 6 months ago by BB_C to c/rust
149
21
submitted 6 months ago by BB_C to c/rust
150
view more: ‹ prev next ›