this post was submitted on 27 Jun 2023
29 points (100.0% liked)

Programming

13377 readers
1 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 1 year ago
MODERATORS
 

I'm looking to get a lemmy bot figured out for posting sports scores in real-time (or near it) like Reddit had for NHL games. The lemmy api reference states that rust has the api as a loadable library, but I've only ever done C/C++ and python. Anything Coursera style to get a basic overview of how to get started in Rust?

I did also see lemmy-bot but it looks like it doesn't handle post editing at the moment, and not sure i really want to learn how to use npm to be honest.

you are viewing a single comment's thread
view the rest of the comments
[โ€“] socphoenix@midwest.social 2 points 1 year ago (1 children)

Thank you! And thank you for the tip I had a feeling it looked just similar enough to be deceiving.

[โ€“] TehPers 2 points 1 year ago

I had a feeling it looked just similar enough to be deceiving.

I think there's a few places where this is true in Rust especially. For example, coming from a C-style language (and Python) the enum keyword throws a lot of people off. In Rust, while you can use an enum to represent a set of "constant" values, it's more common to use it to represent a tagged union, making it more like type from F#:

// a union:
enum Response {
    Html(String),
    Text(String),
    Json(serde_json::Value),
}

// or a more C-style enum:
#[repr(u16)]
enum StatusCode {
    BadRequest = 400,
    NotFound = 404,
    // ...
}

You might find that some concepts look and feel similar to what you might see in traditional OOP languages, but often end up working more like something out of a functional language.