timClicks (Tim McNamara)

Overview

Render Julia fractals. The Julia set and Julia fractals are concepts in the field of mathematics, specifically in a branch called complex dynamics, which deals with complex numbers and their behaviours. Before we dive into defining Julia sets, we need to understand complex numbers.

News

Blog 2 years ago
Integer division is confusing
Can you guess what the output of this program is? // Program A fn main() { let a = 100; let b = 1000; println!("{}", a (b/a)); println!("{}", a (a/b)); } What about this one? // Program B fn main() { let a = 1000; let b = 100; println!("{}", a (b/a)); pri
Read more
Report
Blog 2 years ago
How to use compression algorithms in Rust
Work in Progress Your feedback is welcome. Contact me via the social media links at the top of the page. Creating a uniform interface Each library gets to decide how it works. That makes things relatively complicated when you try to compare one against an
Read more
Report
Blog 2 years ago
How to accept a file as a command-line argument in Rust
Using String as a starting point It's common to ask users where to save files. When defining command-line arguments with clap, it's easy to request these as a String. use clap::Parser; #derive(Debug, Parser) struct Args { #clap(long) save_to: String, } Us
Read more
Report
Blog 2 years ago
Compile-time assertions
An example Here's a snippet from the smol_str crate that demonstrates a neat trick: const _: () = { assert!(WS.len() == N_NEWLINES + N_SPACES); assert!(WS.as_bytes()N_NEWLINES - 1 == b'n'); assert!(WS.as_bytes()N_NEWLINES == b' '); }; These 5 lines of cod
Read more
Report
Blog 2 years ago
Parse CLI arguments without 3rd party crates
Sometimes, bringing in a third-party dependency, such as clap, to your project can feel like a bit of a burden. For example, to improve your prospective users' first impressions, you might want your examples to compile as quickly as possible.It's tempting
Read more
Report
Blog 2 years ago
How to create a 2D matrix in Rust
This article shows you two methods for dynamically creating a two-dimensional matrix with the Rust programming language. If we want to fill up our vector of vectors with a simple constant, such as 0, then there's not much work to do. We can use a nested c
Read more
Report
Blog 3 years ago
Convert a UNIX timestamp to Rust
Sometimes you'll find yourself with a UNIX timestamp in a CSV file or some other external data source. That integer's a fairly straight-forward way to store the time, but it's not very useful to a Rust programmer. Working Code Example For people who light
Read more
Report
Blog 3 years ago
Explaining Rust's Deref trait
On the surface, Deref is merely the trait that is invoked when the "dereference operator", the sometimes unwelcome and intimidating a unary prefixed asterisk (T), is invoked. That is, is describes to Rust how to take a reference as an argument and return
Read more
Report