Rust

6846 readers
64 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 2 years ago
MODERATORS
276
66
submitted 1 year ago* (last edited 1 year ago) by larix to c/rust
 
 

This is my first project in rust, called: since. A small tool to filter logfiles or any other files with a timestamp in it, by a given timestamp.

For example:

since 1h /var/log/messages prints all lines from the last hour. since 00:00 /var/log/messages prints all lines since 00:00.

It would be nice if you could take a look at the code. What would you change, what should I change?

I’m not a professional programmer, this is just a hobby, but I want to learn as much as possible.

277
22
submitted 1 year ago by snaggen to c/rust
278
 
 

Not to throw shade, just wishing that somebody here can understand. Whenever an input is reasonably long, an analyzing function will crash, and this PR aims to fix that with a mechanism that contradicts the maintainer's understanding while a similar C implementation does not need this fix. ~~Clearly, the maintainer has not heard a certain programming mantra...~~

279
280
281
32
submitted 1 year ago by dshank to c/rust
282
283
 
 

I’m personally very excited about this because Rauthy provides a robust foundation of OIDC-based identity for the fedi-connected platform we’re building with Weird netizens.

The addition of “social logins” such as GitHub means indie platforms like Weird can let people easily sign in with the mainstream identity provider they’ve already got, but once they’ve signed up they’ll have the option of using our open source identity provider for other services going forward, thus reducing their dependency on the Big Corp.

284
24
Iced Tutorial 0.12 (leafheap.com)
submitted 1 year ago by autokludge to c/rust
 
 

Original submission text (Bruce Hopkins):

Iced is an amazing library. I chose it for building a simple Code Editor. But Iced severely lacks documentation. I wrote this article as a good entry point into using Iced that can be easy to understand as long as you know Rust. I explain the parts that confused me when I began using the library, so I hope that my mistakes can be useful for someone else.
I might write articles into the more advanced topics in Iced, so if this article is something that you like, let me know.

285
286
8
Biome v1.7 (biomejs.dev)
submitted 1 year ago by arendjr to c/rust
 
 

This new version provides an easy path to migrate from ESLint and Prettier. It also introduces machine-readable reports for the formatter and the linter, new linter rules, and many fixes.

287
 
 

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

288
289
290
291
292
293
294
 
 

I just had a random thought: a common pattern in Rust is to things such as:

let vec_a: Vec<String> = /* ... */;
let vec_b: Vec<String> = vec_a.into_iter().filter(some_filter).collect();

Usually, we need to be aware of the fact that Iterator::collect() allocates for the container we are collecting into. But in the snippet above, we've consumed a container of the same type. And since Rust has full ownership of the vector, in theory the memory allocated by vec_a could be reused to store the collected results of vec_b, meaning everything could be done in-place and no additional allocation is necessary.

It's a highly specific optimization though, so I wonder if such a thing has been implemented in the Rust compiler. Anybody who has an idea about this?

295
296
297
298
14
Rust Analyzer Changelog #228 (rust-analyzer.github.io)
submitted 1 year ago by snaggen to c/rust
299
300
20
pyo3 async runtime (lemmy.physfluids.fr)
submitted 1 year ago by [email protected] to c/rust
 
 

Hello,

I am trying to wrap some Rust code that uses sea-orm compiled with "runtime-tokio-rustls" feature. I am using the new pyo3 "experimental-async" feature, which AFAIK is based on pyo3_async.

So I get that this is supposed to be runtime-agnostic, and not have two event loops, one for python async and one for rust async.

But, how do I tell pyo3 to use tokio runtime specifically? Or, how do I set up Python asyncio eventloop to use tokio somehow?

Indeed, it seems that it does not use tokio runtime, so I get this error when I invoke the rust async function from Python:

pyo3_runtime.PanicException: this functionality requires a Tokio context
view more: ‹ prev next ›