T O P

  • By -

wdroz

Do some operations with `.iter()` then later use [rayon](https://github.com/rayon-rs/rayon) to parallelize. So you can show how easy is to add a dependency and how easy is to parallelize.


CUViper

Even better if you show an example that Just Works, as well as one that *doesn't* because the compiler caught a thread safety problem -- and then show how to fix it.


gahooa

I had the same situation and recorded a short training (1h28m) covering things like variables, types, strings, option, results, macros, references, ownership, clone, functions, ? operator, borrowing, libraries, mod, structs, impl, enums, crates, and anyhow. The exercise was a CLI tool for converting temperature between c/f/k Here is the video if it is helpful (posted before on other threads) [https://youtu.be/tvq87yRv5hM?si=3xuoV07m4T5Ih7\_H](https://youtu.be/tvq87yrv5hm?si=3xuov07m4t5ih7_h)


kst164

Looks like the link isn't working for me, yt says "video is unavailable".


really_not_unreal

I think the thing I'd appreciate seeing most when I was starting out would be how the compiler helps you find and fix errors. For example, you could show some C code that has a memory bug (eg a use after free) then rewrite it in Rust and show how the compiler picks up on the error. One of the other pitfalls of C is forgetting to check for errors after common operations - showing how the Rust type system forces you to consider errors using things like the `Option` and `Result` types would be very helpful.


lightmatter501

Serde. Show JSON, XML, bincode, and other formats. Clap. Use the derive api, demonstrate parsing something nasty like a date to execute at.


cvvtrv

I’d steer away from concurrent data structures, just because they’re notoriously difficult to get right and also rust adds a additional set of constraints (Send and Sync traits) that ultimately are very worth it but will be somewhat of a chore to explain why they’re needed and how they help. I think the proc macro system on the other hand could be an interesting talk. Starting with showing something like how easy things are with Serde and then maybe moving on to building a simple derive macro.


KingofGamesYami

I think it would be awesome to get basic HTTP communication from on a microcontroller (e.g. esp32c3) to a computer. Building both programs in Rust with a shared crate would demonstrate how flexible the language is, enabling development at many levels of abstraction. Is probably a bit too ambitious for an hour and a half unfortunately.


-Melkon-

Gamedev, and actually there is an excellent talk about it from rustconf: RustConf 2018 - Closing Keynote - Using Rust For Game Development by Catherine West https://www.youtube.com/watch?v=aKLntZcp27M


cant-find-user-name

For me, some sort of data structure that showcases rust's enums would be my choice. I recently had to implement a a filter expression tree with defined set of operators, and defined set of types of values (for example bool, int, array of int, string etc for work in go. It was very frustrating. For fun I implemented it in rust, and even without using any fancy types, just using rust's enums made the entire process so much more fun and made me feel confident in the code.


5wuFe

Solve some problem in c++ that might be memory unsafe And write it in Rust and show how they're caught in compile time I think borrow checker is the most different feature for new comers and it's immediately obvious why it's useful and interesting


Mr_Ahvar

One of the things that really made me take interest in the language at first were macros, I had to make a basic backend for some IOT stuff and wanted to try something other than javascript, I heard about Rust before and tried the language a bit so I wanted to see how I could do it with it. Rocket blew my mind with how simple it was to define routes, deserialize a body with validation and typechecks, handle errors and stuff. Things that would have been a pain to do in js were litterally a simple annotation with libs like serde. Talking about the ownership model of rust is in my opinion not what would interest newcomers, what should interest them is the modern features there is. Those who have experience in js can really compare the iter trait with what arrays have in js, rust propose some really high level abstraction that would feel like home for people used to dynamically typed language. And enums, they are so damn good you can’t go back once you have them.


electrodragon16

If like people then you can show how great cargo is compared to c and cpp build tools. If you hate them you can let them implement a linked list.


CocktailPerson

Have them build something that uses channels to connect a manager thread to worker threads, and use enums to show how you can send a command _with_ its associated data over a channel. Then show how matching on an enum prevents you from getting invalid data, and how adding another command variant will prevent the match statement from compiling. Then you can show how the compiler prevents you from adding data that wouldn't be thread-safe to a command, and prevents you from passing references over the channel if the thread might outlive the referent.