Async – join! macro
The join! macro is particularly useful when you need to run multiple asynchronous tasks concurrently and wait for all of them to complete before proceeding further. It’s commonly used in scenarios where you have independent asynchronous operations that can execute simultaneously, and you want to optimize the overall execution time by running them concurrently. Here […]
Create a GUI in Rust with iced – “guissh”
I’ve built a GUI for connecting to remote hosts using SSH. The goal was to learn how to use iced in a real world project called “guissh” – https://youtu.be/uFeOHqomBtI The “guissh” GUI can be adapted to send and receive commands via SSH, eg to a server, router, firewall, switch or IoT device. What is iced? […]
Sorting in Rust
Current implementation The current algorithm is an adaptive, iterative merge sort inspired by timsort. It is designed to be very fast in cases where the slice is nearly sorted, or consists of two or more sorted sequences concatenated one after another. To sort you can use itertools : https://doc.rust-lang.org/std/collections/
Proof of work
Proof of Work (PoW) is a consensus mechanism in blockchain technology. It requires participants, called miners, to solve complex mathematical puzzles to validate transactions and create new blocks. The first miner to solve the puzzle broadcasts the solution, and others verify it. PoW ensures security and decentralization.
Trait Objects and dynamic dispatch
Dynamic dispatch in Rust allows treating different types implementing a trait uniformly through trait objects like Box<dyn Trait>. It provides flexibility by resolving method calls at runtime, enabling runtime polymorphism. This is particularly useful when dealing with collections of diverse types sharing a common trait. “This works differently from defining a struct that uses a […]
Dereference
In Rust, the dereference operator (*) is crucial when working with references to access the underlying values. It is especially relevant in scenarios involving borrowed data, such as when iterating over collections like arrays or vectors. When using iterators, like in a for loop, the iterator provides references to the elements, requiring the dereference operator […]
Generic Type Parameters in Rust
Introduction: Unlock the power of generics in Rust with this concise code example. Learn how to define and leverage generic types using the Query struct, which takes a flexible type parameter T. The accompanying meh function showcases the versatility of generics by accepting a Query<i32> instance. Discover the elegance and expressiveness of Rust’s generic programming […]