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 […]
This should not compile?
Should this compile, my initial expectation was that it would not….. In Rust, moving a value out of a Box or any other owned container is allowed, but it doesn’t invalidate the original variable (v in this case). The variable v is still in scope, and you can continue using it. However, when you print […]
Musl – static linking
I have a chat with chatGPT about Musl, static linking, libc.so.6 and dereferencing smart pointers…here is the conversation! is it possible to make a rust program that prints it’s main.rs and shows what variables live on the stack and which live on the heap? In Rust, it’s not straightforward to inspect the stack and heap […]
Rust – use an upstream crate
How to write your own library and import it from GitHub, via Cargo.toml
🟩 Rust, main.rs is typically used for the entry point of standalone executables, containing the main function. lib.rs is for library code, providing reusable functionality. When building a binary, main.rs is used; for libraries, lib.rs holds the central module.
Dissecting a Rust Program | Axum & Sled
I’ve chosen a project on GitHub to pick apart and study to learn some new code, crates and ideas. The project is : https://github.com/kyoheiu/url-shortener-axum-sled I chose it because I want to learn more about Sled as it’s recommended to be used with BDK (Bitcoin Development Kit) First, let’s have a look at Cargo.toml and see […]