1
19
submitted 6 days ago* (last edited 6 days ago) by QaspR@lemmy.world to c/rust@lemmy.ml

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

2
21
submitted 1 week ago by mawkler@lemmy.ml to c/rust@lemmy.ml

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

3
2
submitted 1 week ago by fzz@programming.dev to c/rust@lemmy.ml

cross-posted from: https://programming.dev/post/15696807

That was a hard long adventure, massive refactoring with bug-fixing 🥵

4
42
submitted 2 weeks ago by tmpod@lemmy.pt to c/rust@lemmy.ml
5
21
submitted 2 weeks ago by notriddle@programming.dev to c/rust@lemmy.ml
6
10
submitted 3 weeks ago* (last edited 2 weeks ago) by john89@lemmy.ca to c/rust@lemmy.ml

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");
}
7
13
submitted 3 weeks ago* (last edited 3 weeks ago) by hohenheim@lemmy.world to c/rust@lemmy.ml

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 ✨

8
5
submitted 3 weeks ago by jamygolden@lemmy.world to c/rust@lemmy.ml

I’m wondering if anyone knows knows of something like stylelint written in rust? I’ve done some searching but can’t find it, but I feel like it must exist in some form.

I’m switching over to Biome from eslint due to the massive speed improvements and I want to do the same with stylelint.

9
9
submitted 4 weeks ago* (last edited 4 weeks ago) by Smorty@lemmy.blahaj.zone to c/rust@lemmy.ml

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

10
2
submitted 1 month ago by nixgoat@slrpnk.net to c/rust@lemmy.ml

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!

11
18
submitted 1 month ago by aev@lemmy.sdf.org to c/rust@lemmy.ml
12
16
submitted 1 month ago by EmDash@lemmygrad.ml to c/rust@lemmy.ml

rustc will use rust-lld by default on x86_64-unknown-linux-gnu on nightly to significantly reduce linking times.

13
13
submitted 1 month ago by tomtau@aussie.zone to c/rust@lemmy.ml
14
24
submitted 1 month ago* (last edited 1 month ago) by fzz@programming.dev to c/rust@lemmy.ml

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! ❤️‍🔥

Project repository, mastodon.

15
13
submitted 1 month ago by hohenheim@lemmy.world to c/rust@lemmy.ml

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 ✨

16
39
submitted 2 months ago by jplatte@discuss.tchncs.de to c/rust@lemmy.ml

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!

17
18
submitted 2 months ago by tracyspcy@lemmy.ml to c/rust@lemmy.ml
18
5
submitted 2 months ago by hohenheim@lemmy.world to c/rust@lemmy.ml

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!

19
8
submitted 2 months ago by eardon@lemmy.ca to c/rust@lemmy.ml

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?

20
7
submitted 2 months ago* (last edited 2 months ago) by bi_tux@lemmy.world to c/rust@lemmy.ml

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);
}
21
27
submitted 2 months ago by redempt@lemmy.world to c/rust@lemmy.ml

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!

22
34
submitted 3 months ago by PaoloBarbolini@lemmy.ml to c/rust@lemmy.ml
23
11
ReactNative but Rust? (programming.dev)
submitted 3 months ago by GGORG@programming.dev to c/rust@lemmy.ml

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

24
34
submitted 3 months ago by tracyspcy@lemmy.ml to c/rust@lemmy.ml

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

25
27
submitted 3 months ago by dessalines@lemmy.ml to c/rust@lemmy.ml
view more: next ›

Rust Programming

7734 readers
1 users here now

founded 5 years ago
MODERATORS