Rust Programming
- Rust Project goals for 2024
Rust Project goals for 2024
https://blog.rust-lang.org/2024/08/12/Project-goals.html
cc: @rust@lemmy.ml
- #rust folks it's supposed to throw this error without lazy_static crate , but it doesn't?
\#rust folks it's supposed to throw this error without
lazy_static
crate , but it doesn't? https://git.sr.ht/\~carnotweat/morning-rust/tree/main/item/sum.rs#L14 cc @rust @learningrustandlemmy - GitHub - Atreyagaurav/numrng: Terminal Command to generate list of numbers from human-readable representationgithub.com GitHub - Atreyagaurav/numrng: Terminal Command to generate list of numbers from human readable representation
Terminal Command to generate list of numbers from human readable representation - Atreyagaurav/numrng
cross-posted from: https://lemmy.world/post/18129059
> This feels like it should already be a feature in a terminal. But I didn't find anything that let me do this efficiently. > > I had a rust library for converting list like
1-4,8-10
into vectors, but thought I'd expand it into a command line command as well, as it is really useful when I want to run batch commands in parallel using templates. > > I wanted to share it since it might be a useful simple command for many people. - GitHub - Atreyagaurav/local-mpv: Run MPV with a webserver to control from local network
Hi all,
mpv communities seem to be tiny in lemmy, so I'm sharing it here.
This is a program I made for music control from local network.
You can run it in a computer with some local media files, or youtube links or any other links yt-dlp supports. And then with the server, you can control the media player and the playlist from any devices in your local network. So that you can just show a QR code or something to house guests for parties, or have it bookmarked within family to control the music.
I wanted to make something similar to how youtube app let's you play in TV and such, but my skills were not enough to do that. So I tried a simple alternative that works with computers. In an ideal world, I could make "Play with local mpv server" option come while on other android apps, but I have zero experience in android app development and it looks complicated.
I know some other programs also give option to control media, but I wanted to give it a go with a simple implementation. Making the web-server was a tricky part. Only tutorial from the rust book was useful here as every other web server developement in rust seems to be async ones using libraries so I would have to make a complicated system to communicate with the mpv. Using the simple Tcp connection let me make a thread with mpv instance in the scope. I do need to support https and file uploads and other things, but I haven't had any luck finding a solution that works with simple Tcp connection like in the tutorial. Let me know if you know anything.
Github: https://github.com/Atreyagaurav/local-mpv
- Stdin takes in values from before my code even starts. How do I prevent this?
For context, I am using the libraries bevy and print_typewriter.
I noticed that before the program even starts, I am able to type in characters. This is bad, since when I ask for the user's input, the previous characters are included inside of it.
How do I make sure that only the user's input after the program starts, and after I print a question gets in?
- Jiff is a new date-time library for Rust that encourages you to jump into the pit of successgithub.com GitHub - BurntSushi/jiff: A date-time library for Rust that encourages you to jump into the pit of success.
A date-time library for Rust that encourages you to jump into the pit of success. - BurntSushi/jiff
In which BurntSushi does date/time handling. Reddit discussion, HN discussion.
> Before someone asks: > > - Comparison with other Rust datetime crates > - Why build another datetime library? > - Why not contribute to an existing library instead of building a new one?
- Anyone looking for a fun small rust project? Create a crate for cleaning urls, based on the ClearUrls project
This would entail:
- Pulling in the ClearUrls rules as a git submodule.
- Reading / transforming the json there into Rust structs.
- Creating a Rust crate that runs a
.clean(input_url) -> String
Lemmy issue: https://github.com/LemmyNet/lemmy/issues/4905
- Diesel-Async 0.5.0 released, with SQLite supportgithub.com Release Diesel-Async 0.5.0 · weiznich/diesel_async
Added type diesel_async::pooled_connection::mobc::PooledConnection MySQL/MariaDB now use CLIENT_FOUND_ROWS capability to allow consistent behaviour with PostgreSQL regarding return value of UPDATe ...
> - Added type
diesel_async::pooled_connection::mobc::PooledConnection
> - MySQL/MariaDB now useCLIENT_FOUND_ROWS
capability to allow consistent behaviour with PostgreSQL regarding return value ofUPDATe
commands. > - The minimal supported rust version is now 1.78.0 > - Add aSyncConnectionWrapper
type that turns a sync connection into an async one. This enables SQLite support for diesel-async > - Add support fordiesel::connection::Instrumentation
to support logging and other instrumentation for any of the provided connection impls. > - Bump minimal supportedmysql_async
version to 0.34 > > A special thanks goes to @momobel and Wattsense for contributing theSyncConnectionWrapper
implementation. > > To support future development efforts, please consider sponsoring me on GitHub. > > Full Changelog:v0.4.0...v0.5.0
- Mannheim (DE) Meetup on July 16rheinneckar.events Nix Your Bugs & Rust Your Engines #4
Jul 16, 2024, 6:00:00 PM - GMT+2 - Mafinex Technologiezentrum, 68163, Mannheim, Deutschland - Nix Your Bugs & Rust Your Engines is a new meetup for people in the Rhein-Neckar region that are interested in Rust (the programming language), Nix (the package manager), or NixOS (the Linux distributi…
It's less than two weeks until our next Rust and NixOS meetup in Mannheim, Germany. We're meeting on the 16th of July at the Mafinex technology center close to the main station. If you want to join us, please sign up for the event on Mobilizon (no account required) or Meetup.com.
https://rheinneckar.events/events/9d740b89-7713-4e19-a112-45aff1670f0f
https://www.meetup.com/hackschool-rhein-neckar/events/301504325/
As first talk, we will hear Andre Dossinger on "Using NixOS for Pragmatical Self-hosting", where he will show us how NixOS can be used in a problem oriented manner to preserve privacy and make complex setups manageable. Questions and discussions are highly encouraged!
Then, we will hear Benjamin Sparks on "Reading from Streams and Writing to Sinks" using Rust and Tokio, with a focus on low runtime overhead, safe buffer management, and robust error handling. He will show us the types and traits Tokio leverages to efficiently decode bytes and encode structured data in a type-safe manner is presented, and give us a practical demonstration of codecs for two different protocols.
Finally, Stefan Machmeier of the EMCL at Heidelberg University will give us an introduction to Nix Flakes, the experimental dependency management system built into Nix since version 2.4 that can be used for reusable Nix libraries as well as your own Nix packages and NixOS configurations.
The talks will be recorded and uploaded after the meetup.
- Rust has a HUGE supply chain security problem | Sylvain Kerkour | July 2, 2024kerkour.com Rust has a HUGE supply chain security problem
This post is part of my Summer of Rust 2024 serie: weekly (or more) quickies about how to write great Rust code so you will be ready to rock at the end of the summer and find a new exciting job 🤘 Dont forget to Subscribe (Email & RSS) "If
cross-posted from: https://programming.dev/post/16349359
> July 2, 2024 > > Sylvain Kerkour writes: > > > Rust adoption is stagnating not because it's missing some feature pushed by programming language theory enthusiasts, but because of a lack of focus on solving the practical problems that developers are facing every day. > > > > ... no company outside of AWS is making SDKs for Rust ... it has no official HTTP library. > > > > As a result of Rust's lack of official packages, even its core infrastructure components need to import hundreds of third-party crates. > > > > - cargo imports over 400 crates. > > > > - crates.io has over 500 transitive dependencies. > > > > ...the offical libsignal (from the Signal messaging app) uses 500 third-party packages. > > > > ... what is really inside these packages. It has been found last month that among the 999 most popular packages on crates.io, the content of around 20% of these doesn't even match the content of their Git repository. > > > > ...how I would do it (there may be better ways): > > > > A stdx (for std eXtended) under the rust-lang organization containing the most-needed packages. ... to make it secure: all packages in stdx can only import packages from std or stdx. No third-party imports. No supply-chain risks. > > [stdx packages to include, among others]: > > > gzip, hex, http, json, net, rand > > Read Rust has a HUGE supply chain security problem > > --- > ### Submitter's note: > > I find the author's writing style immature, sensationalist, and tiresome, but they raise a number of what appear to be solid points, some of which are highlighted above.
- This Month in Rust GameDev: June Edition Released + Call for Submissions for Julygamedev.rs This Month in Rust GameDev #52 - June 2024
Welcome to the 52th issue of the Rust GameDev Workgroup’s monthly newsletter. Rust is a systems lang…
The June edition of "This Month in Rust GameDev" has just landed!. With it, we have also added the option to subscribe to the newsletter by email. You can find the subscription form by scrolling down on https://gamedev.rs/.
This is also your call for submissions! Got a game you're tinkering on? A crate for fellow game devs? Do you want to share a tutorial you've made? Are you excited about a new feature in your favorite engine? Share it with us!
You can add your news to this month's WIP newsletter and mention the current tracking issue in your PR to get them included. We will then send out the newsletter at the start of next month.
Happy coding 🌟
- Ferris and Corro wallpaper
Have been struggling to find some nice Rust wallpapers, so I decided to make one for myself.
On the left is Ferris on a canvas. On the right is Corro the unsafe Rusturchin. (The contrast between safe (art-like) and unsafe Rust is supposed to be the joke here.)
Edit: The original image is 1080p. I got the drawings of Ferris and Corro from rustacean.net
- I've created a CLI tool to download Rust web books as EPUBgithub.com GitHub - mawkler/rust-book-to-epub: Rust Book to EPUB converter
Rust Book to EPUB converter. Contribute to mawkler/rust-book-to-epub development by creating an account on GitHub.
cross-posted from: https://lemmy.ml/post/17090149
> Hi! I've created a CLI tool for downloading Rust web books (like The Rust Programming Language) as EPUB, so that you can easily read them on your e-book reader. The tool is heavily based on this gist and a lot of proompting. > > Check it out here: https://github.com/mawkler/rust-book-to-epub
- Cargo-playdate 0.5 released 🎉github.com Release 2024.06.18 · boozook/playdate
TL;DR What's Changed Refactoring some build system parts including final product matching, that gives support of cargo's auto-targets such as bin and example, as well as args like --all-targets me...
cross-posted from: https://programming.dev/post/15696807
> That was a hard long adventure, massive refactoring with bug-fixing 🥵
- Announcing Rust 1.79.0 | Rust Blogblog.rust-lang.org Announcing Rust 1.79.0 | Rust Blog
Empowering everyone to build reliable and efficient software.
- Announcing the Safety-Critical Rust Consortiumfoundation.rust-lang.org Rust Foundation
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.
- [SOLVED] Is there a way to start and stop chromedriver/geckodriver with Rust and Selenium (thirtyfour) automatically like in Python?
So, apparently the chrome/geckodriver processes will terminate on their own if the user sends ctrl+c to the console. It will not terminate on its own if the program finishes running naturally.
If you're interested in terminating it on your own, like I also was, here is how I went about it.
``` use std::process::{Child, Command};
fn main() { let mut s = Server::default(); s.start(); s.shutdown(); }
struct Server { child: Option<Child> }
impl Default for Server { fn default() -> Self { Self { child: None } } }
impl Server { fn start(&mut self) { self.child = Some(Command::new("./chromedriver") .spawn() .expect("ls command failed to start")); }
fn shutdown(&mut self) { input(None); // wait for input so you can observe the process self.child.as_mut().unwrap().kill(); self.child.as_mut().unwrap().wait(); println!("shutdown"); } }
pub fn input(prompt: Option<String>) { let mut input = String::new(); match prompt { Some(prompt) => println!("{}", prompt), None => () } io::stdin().read_line(&mut input).expect("Failed to read input"); } ```
- This Month in Rust GameDev: May Edition Released + Call for Submissions for June
The May edition of "This Month in Rust GameDev" has just landed!.
With it, we also released a statistical analysis of the survey we ran last month. Thank you very much to the 52 readers who gave us their feedback on how to improve the newsletter! You rock!
This is also your call for submissions. Got a game you're tinkering on? A crate for fellow game devs? Do you want to share a tutorial you've made? Are you excited about a new feature in your favorite engine? Share it with us! You can add your news to this month's WIP newsletter and mention the current tracking issue in your PR to get them included. We will then send out the newsletter at the start of next month.
Happy coding ✨
- [SOLVED] Rust-analyzer only somewhat working?
Video
Click to view this content.
The autocompletion works (mostly) but for example Vec::new() doesn't highlight anything at all. I do get errors when not putting a semicolon, but things like passing too many arguments into the println macro doesn't throw an error. Or how shown in this example, it did not autocomplete the clone method, while also just accepting .clo; at the end of a String (it also didn't autocomplete "String"). In the video I show how it also gives me a recommendation for setting vec![] as a type, which doesn't make any sense. It only seems to a very limited selection of methods and some words I already used in the script. Is this how it's supposed to be, or do I have some very old version perhaps?
EDIT: Look in description for the fix
- Shoelace: Alternative frontend for Instagram's Threads
cross-posted from: https://slrpnk.net/post/9960845
> Hello Lemmy! Yesterday I released the first version of an alternative frontend for Threads: Shoelace. It allows for fetching posts and profiles from Threads without the need of any browser-side JavaScript. It's written in Rust, and powered by the spools library, which was co-developed between me and my girlfriend. Here's a quick preview: > > !A screenshot of Shoelace's homepage, showing the logo on top, the title "Shoelace", the subtitle "an alternative frontend for Threads", an input bar with the tooltip "Jump to a profile...", and at the bottom three links: "hub", "donate", and "v0.1". > > !Mark Zuckerberg's profile on Shoelace, showing three posts: One showcasing columns on the official Threads frontend, another congratulating himself for 1.2M+ downloads in his company's new AI software, and the glimpse of a post related to the "metaverse" > !Post by münecat on Shoelace, announcing the release of a video essay criticizing the field of evolutionary psychology > > The official public instance (at least for now) is located at https://shoelace.mint.lgbt/, if y'all wanna try it out. There's also instructions to deploy it inside the docs you can find in the README. Hope y'all enjoy it!
- GPT-Burn: a simple and concise implementation of GPT in Rust and Burngithub.com GitHub - felix-andreas/gpt-burn: Implementation of the GPT architecture in Rust 🦀 + Burn 🔥
Implementation of the GPT architecture in Rust 🦀 + Burn 🔥 - felix-andreas/gpt-burn
- Faster linking times on Linux using `rust-lld`
rustc will use rust-lld by default on x86_64-unknown-linux-gnu on nightly to significantly reduce linking times.
- Early pest3 prototype was released on crates.iogithub.com 🤩Let's play with `pest3 0.0.0-prealpha0`!😍 · pest-parser pest · Discussion #1016
The early alpha prototype of pest3, the next major revision of the pest parser generator library, was published on crates.io! Read more for details on how you can experiment with this prototype. Wh...
- Rusty Playdate - Toolset and API
I’m working on a big project in #Rust, there is toolset and API for #Playdate.
All going great, moving to stabilization step by step, but I’m tired of looking at the dull 90⭐️. Seriously, could you please throw me into the trends of the github, please! ❤️🔥
- This Month in Rust GameDev: April Edition Released + Call for Submissions for May
The April edition of "This Month in Rust GameDev" has just landed!.
You may have noticed that this marks the first release since quite a while. To revive the newsletter, we made some organisational changes. We want to continue improving the project, so we've put together a survey for you to tell us how the newsletter should evolve. We'd be happy if you filled it out and / or shared it with your fellow game devs 🙂
This is also your call for submissions for May's edition!
Happy coding ✨
- Anybody wanna try a new static site generator?github.com GitHub - jplatte/hinoki: A simple, yet very flexible static site generator.
A simple, yet very flexible static site generator. - jplatte/hinoki
I just released v0.1.0 of hinoki, my static site generator :)\ The
README.md
should explain usage, and you can also see how I ported my blog to it here.This project started because I'm not entirely happy with Zola, which does not support customizing page paths much (e.g.
/year/month/day/title/index.html
style paths) and made some other design decisions that I wanted to explore alternatives to.You can download the binary from GitHub releases, or
cargo install
it from git.Any feedback is appreciated, here or in the GitHub issues!
- This Month in Rust GameDev: Call for Submissions!github.com Newsletter 50: April 2024 · Issue #1474 · rust-gamedev/rust-gamedev.github.io
Newsletter 50: April 2024 Editors: @janhohenheim, @AngelOnFira, and @mamaicode Another month has gone by, so it's time to put together the Rust Gamedev newsletter with April's news! Current Schedul...
The Rust gamedev working group's newsletter "This Month in Rust GameDev" has been rebooted, starting this April 🎉
This is your call for submissions. Got a game you're tinkering on? A crate for fellow game devs? Do you want to share a tutorial you've made? Are you excited about a new feature in your favorite engine? Share it with us! You can add your news to this month's WIP newsletter and mention the current tracking issue in your PR to get them included. We will then send out the newsletter at the start of next month.
Happy coding!
- Where can we download the Rust manual for free?
https://doc.rust-lang.org/book/ links to a site that's charging an absurd $40 for ebook format.
Where can we download it for free?
- Need help writing a sprite update with bevy
So I want to update the sprite so my character looks in a different direction each time the player presses left/right, how could I do this? I can't do it in the setup fn, since it's a startup system, appreciate any help
EDIT: changed formating
here is my code:
``` use bevy::prelude::*;
`fn main() { App::new() .add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) // prevents blurry sprites .add_systems(Startup, setup) .add_systems(Update, animate_sprite) .add_systems(Update, player_movement_system) .run(); }
const BOUNDS: Vec2 = Vec2::new(1200.0, 640.0); static mut FLIP_BOOLEAN: bool = false;
fn set_flip_boolean(boolean: bool) { unsafe { FLIP_BOOLEAN = boolean; } }
fn get_flip_boolean() -> bool{ unsafe { FLIP_BOOLEAN } }
#[derive(Component)] struct Player { movement_speed: f32, }
#[derive(Component)] struct AnimationIndices { first: usize, last: usize, }
#[derive(Component, Deref, DerefMut)] struct AnimationTimer(Timer);
fn animate_sprite( time: Res<Time>, mut query: Query<(&AnimationIndices, &mut AnimationTimer, &mut TextureAtlas)>, ) { for (indices, mut timer, mut atlas) in &mut query { timer.tick(time.delta()); if timer.just_finished() { atlas.index = if atlas.index == indices.last { indices.first } else { atlas.index + 1 }; } } }
fn setup( mut commands: Commands, asset_server: Res<AssetServer>, mut texture_atlas_layouts: ResMut<Assets<TextureAtlasLayout>>, ) { let texture = asset_server.load("sprites/Idle01.png"); let layout = TextureAtlasLayout::from_grid(Vec2::new(64.0, 40.0), 5, 1, None, None); let texture_atlas_layout = texture_atlas_layouts.add(layout); let animation_indices = AnimationIndices { first: 0, last: 4 }; let boolean = get_flip_boolean(); commands.spawn(Camera2dBundle::default()); commands.spawn(( SpriteSheetBundle { texture, atlas: TextureAtlas { layout: texture_atlas_layout, index: animation_indices.first, },
..default() }, Player { movement_speed: 500.0, }, animation_indices, AnimationTimer(Timer::from_seconds(0.1, TimerMode::Repeating)), )); }
fn player_movement_system( time: Res<Time>, keyboard_input: Res<ButtonInput<KeyCode>>, mut query: Query<(&Player, &mut Transform)>, ) { let (guy, mut transform) = query.single_mut();
let mut movement_factor = 0.0;
let mut movement_direction = Vec3::X;
if keyboard_input.pressed(KeyCode::ArrowLeft) { movement_factor -= 1.0; movement_direction = Vec3::X; set_flip_boolean(true); }
if keyboard_input.pressed(KeyCode::ArrowRight) { movement_factor += 1.0; movement_direction = Vec3::X; set_flip_boolean(false); }
if keyboard_input.pressed(KeyCode::ArrowUp) { movement_factor += 1.0; movement_direction = Vec3::Y; }
if keyboard_input.pressed(KeyCode::ArrowDown) { movement_factor -= 1.0; movement_direction = Vec3::Y; }
let movement_distance = movement_factor * guy.movement_speed * time.delta_seconds(); let translation_delta = movement_direction * movement_distance; transform.translation += translation_delta;
let extents = Vec3::from((BOUNDS / 2.0, 0.0)); transform.translation = transform.translation.min(extents).max(-extents); } ```
- Untwine - the pattern-matching parsing library capable of a 12 line JSON parser with pretty errorsgithub.com GitHub - boxbeam/untwine
Contribute to boxbeam/untwine development by creating an account on GitHub.
Been working on this a few months. It's inspired by previous generations of parser generators, and by my own previous work generating ast lexers from grammar files. This integrates seamlessly with the type system, allowing you to declare your syntax, extract only the data you want as variables, and evaluate them easily. And just from a simple description of your syntax, you'll get beautiful errors which visually point out structures in the input.
With this I have been able to implement a (mostly complete) JSON parser in just 12 lines of parsing logic, and a pmdas-respecting expression parser in just 6 (with one helper function to apply individual operators).
Examples available on the github repo, also now available on crates.io!
- ReactNative but Rust?
Hi.
Rust can run on anything from web browsers to Adruinos. BUT can you make Android/iOS apps with it? I heard that you can make the backend of your app in Rust and then incorporate it into your Java/Kotlin app, but I'm looking for something like React Native or Flutter, where you can build the entire app (including UI and interacting with native APIs) in Rust without writing a single line of Java/Kotlin.
Does something like that exist? If not, then is anyone working on it?
Oh, and I don't mean I want one of the many libraries which just compile your code to WASM and run the app in a WebView... I want something that lets me make native UIs - like React Native or Flutter.
Thanks
- Mastering rust with basic data structures and algorithms
Rust is beautiful and at the same time pretty hard language to learn. While mastering it and digging deeper, I decided to play around basic data structures and algorithms. I put a repo with some theory, implementations and examples on github mainly for myself, but maybe someone will find it helpful, or share more effective solutions. For now, just a few topics are covered, and I'm going to update it from time to time.
repo: https://github.com/tracyspacy/algos_data_structures_rust
- Byron/dua-cli: View disk space usage and delete unwanted data, fast.github.com GitHub - Byron/dua-cli: View disk space usage and delete unwanted data, fast.
View disk space usage and delete unwanted data, fast. - Byron/dua-cli
- How to make plugins?
I have a plugin trait that includes some heavy types that would be almost impossible to wrap into a single API. It looks like this:
rust pub struct PluginContext<'a> { pub query: &'a mut String, pub gl_window: &'a GlutinWindowContext, flow: PluginFlowControl, pub egui_ctx: &'a Context, disable_cursor: bool, error: Option<String>, } pub trait Plugin { fn configure(&mut self, builder: ConfigBuilder) -> Result<ConfigBuilder, ConfigError> { Ok(builder) } fn search(&mut self, ui: &mut Ui, ctx: &mut PluginContext<'_>); fn before_search(&mut self, _ctx: &mut PluginContext<'_>) {} }
Here is what I considered:
- Keeping all plugins in-repo. This is what I do now, however I'd like to make a plugin that would just pollute the repository. So I need another option that would keep the plugins' freedom as it is right now, but with the possibility to move the plugin out to a separate repository.
- I tried to look into dynamic loading, and since rust doesn't have a stable ABI, I'm okay with restricting the rust versions for the plugin ecosystem. However, I don't think it's possible to compile this complex API into a dynamic lib and load it safely.
- I'm also ok with recompiling the app every time I need a new plugin, but I would like to load these plugins automatically, so I don't want to change the code every time I need a new plugin. For example, I imagine loading all plugins from a folder. Unfortunately, I didn't find an easy solution for this neither. I think I will write a build macro that checks the
~/.config/myapp/plugins
and include all of them into the repo.
Do you have any better ideas, suggestions? Thanks in advance.
(For context, this the app I'm writing about: https://github.com/fxdave/vonal-rust)
- How long a crate can be left unupdated to consider it out of date?
When I install some Linux app from, let's say GitHub, I can feel how long without updates means the project is not maintained.\ For example last commit being 5 years ago for GTK app is a long time and this is considered an abandoned repo. For super simple things like cowsay it's not that simple but still I can feel it.
How is that with crates with Rust? I see a lot of parsers or web libraries that are not updated for a year, two years, three years... How old is too old?\ Also, many of them have a version 0.x.x, so can I even consider them stable?