![rust](https://lemmy.ml/pictrs/image/oHAh2Yu3zC.png?format=webp&thumbnail=48)
Rust Programming
- 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?
- Serving Astro with Rustwww.yieldcode.blog Serving Astro with Rust - Dmitry Kudryavtsev
I wanted to turn one of my side projects into a statically generated website. But the backend was written in Rust. So I decided to combine them.
- Boris: interactive ownership lifetime vizualizergithub.com GitHub - ChristianSchott/boris: Visualizing Ownership and Borrowing in Rust Programs
Visualizing Ownership and Borrowing in Rust Programs - ChristianSchott/boris
similar to other tools. the author says "RustViz is a bit more of a purely educational tool, as code has to be annotated manually, while Boris aims to be more of a development assistance"
- Translating OpenStreetMap data to HTML5 Canvas with Rust and WebAssembly | Programming | mary.codesmary.codes Translating OpenStreetMap data to HTML5 Canvas with Rust and WebAssembly | Programming | mary.codes
Using the Overpass API to read OSM data, parsing the data with Rust, and then drawing the map onto HTML5 canvas.
Using the Overpass API to read OSM data, parsing the data with Rust, and then drawing the map onto HTML5 canvas.
- I made a Wind Waker shader for Bevy
Video
Click to view this content.
I recently made a fairly simple shader heavily inspired by the one used for characters in The Legend of Zelda: The Wind Waker. I've got all my info on how it worked on the GameCube from this amazing video
Check out the source at bevy_wind_waker_shader
Here are some screenshots :)
Sphere:
!Sphere
Light throughout day:
Daylight
!Daylight
Night time
- 2023 Annual Rust Survey Results | Rust Blogblog.rust-lang.org 2023 Annual Rust Survey Results | Rust Blog
Empowering everyone to build reliable and efficient software.
- Any MT testing framework around shuttle MT testing cratedocs.rs shuttle - Rust
Shuttle is a library for testing concurrent Rust code, heavily inspired by Loom.
Anyone aware of a testing framework hopefully integrating well, and abstracting the shuttle testing functionality?
BTW I found rtest, but it doesn't in particular abstracts shuttle at all, it's a fixtures generic framework.
Planning to use shuttle to do MT testing targeting C binded code, and looking for a way to abstract as much as possible the shuttle scheduler trait and such...
Thanks !
- Stract: Independent and Open Search
publicado de forma cruzada desde: https://infosec.pub/post/8054415
> Stract is an open source search engine where the user has the ability to see exactly what is going on and customize almost everything about their search results. It's a search engine made for hackers and tinkerers just like ourselves. No more searches where some of the terms in the query arent used, and the engine tries to guess what you really meant. You get what you search for.
Fun fact: It's written in Rust! (nearly 90%) https://github.com/StractOrg/stract
- New community for learning rust and the lemmy codebase togetherlemmy.ml Learning Rust and Lemmy - Lemmy
# Welcome A collaborative space for people to work together on learning Rust, learning about the Lemmy code base, discussing whatever confusions or difficulties we’re having in these endeavours, and solving problems, including, hopefully, some contributions back to the Lemmy code base. Rules TL;DR: ...
Hi all,
We've started a new community for learning rust and/or the lemmy codebase together.
Come join in: !learningrustandlemmy@lemmy.ml
The idea is that there are probably a good amount of people interested in learning rust, or, interested in contributing to or using the lemmy codebase, but find it difficult to get started ... so basically why not start a sort of study group or reading group or support channel style of community? Here's where the idea was originally suggested: https://lemmy.ml/post/11232276
We're just putting the place together and sorting out how it could work, but all kinds of inputs and levels of expertise are welcome!
- Yarn Spinner for Rust
I am delighted to finally release a project that has been cooking for quite a while: Yarn Spinner for Rust 🎉 . Some of you might remember this under the name Yarn Slinger, but the kind folks at Secret Lab have allowed me to use their trademark! Yay!
What is Yarn Spinner?
It's a friendly tool that helps you write dialog! See for yourself at the live demo. You can also check out this or this GDC talk about the original C# implementation. What I have released today is the Rust port for the project, with first-class support for Bevy!
Quickstart
Writing a dialog with Yarn Spinner is as easy as whipping up a simple screenplay: ``` // assets/dialogue/hello_world.yarn title: Start --- Ancient Reptilian Brain: There is nothing. Only warm, primordial blackness. Your conscience ferments in it -- no larger than a single grain of malt. You don't have to do anything anymore. Ancient Reptilian Brain: Ever. Ancient Reptilian Brain: Never ever. -> Never ever ever? Ancient Reptilian Brain: Never ever ever ever, baby! -> (Simply keep on non-existing.)
Ancient Reptilian Brain: An inordinate amount of time passes. It is utterly void of struggle. No ex-wives are contained within it. === ``` Pretty simple file format, right? Check out the general Yarn Spinner documentation for more or look into the Bevy examples.
- My minimalistic habit tracker CLI app written in rust. Great way to spend weekends and a good cause to play with ratatui
I made it for myself as the simplest way to keep track of positive routines. The concept is simple: Track the activities that make up your perfect day and monitor your daily progress effortlessly. Here is also a github link for those who interested : https://github.com/tracyspacy/yacht