Rust

6128 readers
44 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
1
 
 

Hello,

As I said in the previous post that I have started learning Rust and made a simple fibonacci series generator. Today I made a palindrome string checker. it's very basic. I haven't used Enum or Struct in the code since I don't think it's necessary in this simple code.

here is the code:

use std::io;

fn main() {
    let mut input = String::new();
    let stdin = io::stdin();
    stdin.read_line(&mut input).unwrap(); // we want to exit in case it couldn't read from stdin

    input = input.replace("\n", ""); // Removing newline

    let mut is_palindrome: bool = true;
    for i in 0..input.len()/2 {
        let first_char: &str = &input[i..i+1];
        let last_char: &str = &input[input.len()-i-1..input.len()-i];
        if first_char != "\n" {
            if first_char != last_char {
                is_palindrome = false;
            }
        }
    }

    println!("palindrome: {}", is_palindrome);
}
2
3
21
submitted 1 day ago by kvark to c/rust
 
 

End of the year release with lots of improvements across the board.

4
5
18
November project goals update (blog.rust-lang.org)
submitted 6 days ago* (last edited 6 days ago) by [email protected] to c/rust
6
 
 

I've been trying to learn the fuzzing library LibAFL for a while now, but I never seem to be able to fully grasp the essential parts. I've read tutorials, followed along tutorials, read the whole LibAFL book (that's still under construction), and have read a few of the examples in the repo. You could say I'm still in tutorial hell, honestly.

I'm trying to write a simple fuzzer for a malware code sample (MooBot) and I've been trying to figure out two things: how to find the input that has the maximum run time for a function, and how to not run malware directly on my computer. One of them should be more important than the other, but given my lack of expertise in LibAFL right now, I'm focused on the former. For my example, I noticed that there's a custom trim function in MooBot that helps sanitize input:

void trim(char *str)
{
        int i, begin = 0, end = strlen(str) - 1;

    while (isspace(str[begin]))
        begin++;

    while ((end >= begin) && isspace(str[end]))
        end--;

    for (i = begin; i <= end; i++)
        str[i - begin] = str[i];

    str[i - begin] = '\0';
}

This is what I test in my harness. I know I could probably logic my way into finding the input that has the max run time, but I'm using this as an exercise for LibAFL and using the rust FFI. The problem is how to deal with feedbacks and observers. I currently have this with no observers:

let mut feedback = CrashFeedback::new();
let mut objective = CrashFeedback::new();

Which simply reports an input if it crashes the program. It works for inital fuzzing, but now that I'm trying to find an input that maximizes run time this won't work. I tried to figure if there was a maximization feedback that would work with the time observer, but the only feedback that maximizes anything is the MaxMapFeedback which doesn't seem compatible with the time observer.

What I'm envisioning is something like this:

let mut observer = TimeObserver::new();
let mut feedback = MaximizeFeedback::new(&observer);

I think the solution has something to do with MapFeedbacks, but I'm not exactly sure how they work.

7
27
submitted 1 week ago* (last edited 1 week ago) by [email protected] to c/rust
 
 

Hi, I've been working on this app for playing MIDI files with different soundfonts. It's been a few months of work, but I think it's inching towards being good enough to publish for real. There are still a couple fundamental features missing before v1.0.0, but I thought it would be a good time to share it and ask for opinions in a programming community. Any critique on the app, or code? Do people out there even care about midi files this much? Thanks.

img

8
23
submitted 1 week ago* (last edited 1 week ago) by [email protected] to c/rust
 
 

I was recently furloughed from work, so in between job applications, I decided to polish off Sonarr support in my Managarr TUI. Thus, I'm very proud to announce the beta release of Managarr with Sonarr support!

TL;DR: Managarr is a TUI and CLI for managing your Servarr instances. As of now, it now supports both Radarr and Sonarr and all the features that are available in the UI are also available in the CLI for scripting and additional automation.

The new version has the following features:

  • Wider platform support (Windows, Mac, Linux, x86_64 and arm64)
  • View your library, downloads, blocklist, episodes
  • View details of a specific series, or episode including description, history, downloaded file info, or the credits
  • View your host and security configs from the CLI to programmatically fetch the API token, among other settings
  • Search your library
  • Add series to your library
  • Delete series, downloads, indexers, root folders, and episode files
  • Trigger automatic searches for series, seasons, or episodes
  • Trigger refresh and disk scan for series and downloads
  • Manually search for series, seasons, or episodes
  • Edit your series and indexers
  • Manage your tags
  • Manage your root folders
  • Manage your blocklist
  • View and browse logs, tasks, events queues, and updates
  • Manually trigger scheduled tasks
  • Manually trigger scheduled tasks
  • And more!

Here's some screenshots of the Sonarr tab:

Thanks to everyone's feedback when I first posted the alpha release here, this version sports a handful of additional performance improvements and platform support.

This is now technically in beta, so if anyone encounters any issues, please let me know!

9
10
11
12
 
 

Hey all! Read a lot of good things about Rust and I was getting pretty bored and often annoyed with building new FastAPI apps. I'm just getting started, from my research Poem seems to be doing the same thing as FastAPI kinda and I'm using SeaORM for the DB.

So far I'm loving it, Cargo.toml looks a lot like Poetry in Python but in VSCode it magically shows me the latest versions of all dependencies. Debugging is really nice because I can just copy & paste compiler messages into an LLM or Google them. It was a bit of a hassle to get all dependencies to work together and to get the thing to compile at first but now it works and I'm happy.

That being said is there anything else I need to know? I still have a very limited understanding of the whole ownership thing but e.g. I understand the benefits of passing variables instead of copying them so I guess that's a start?

13
 
 

The Rust Foundation is an independent non-profit organization to steward the Rust programming language and ecosystem, with a unique focus on supporting the set of maintainers that govern and develop the project.

14
15
37
submitted 2 weeks ago by kvark to c/rust
16
31
submitted 3 weeks ago by snaggen to c/rust
 
 

fjärrinlägg från: https://lemmy.world/post/22673996

This mod is written in an unconventional way: it is written in Rust. The Rust code is here. It uses JNI and JVMTI to interact with Java objects. The only Java code in this mod is for loading the compiled native binary into memory.

17
17
submitted 3 weeks ago by antoyo to c/rust
 
 

I'm happy to have received reviews and merged more than 10 patches to GCC lately (12, to be exact). There are around 6 left to merge (and a couple of others to send to the mailing list).

18
19
63
Announcing Rust 1.83.0 (blog.rust-lang.org)
submitted 3 weeks ago by snaggen to c/rust
20
49
submitted 3 weeks ago by snaggen to c/rust
21
45
submitted 3 weeks ago by snaggen to c/rust
22
20
submitted 4 weeks ago by snaggen to c/rust
23
24
25
view more: next ›