Rust Ownership

Understanding Ownership Ownership is Rust’s most unique feature and has deep implications for the rest of the language. It enables Rust to make memory safety guarantees without needing a garbage collector, so it’s important to understand how ownership works. In this chapter, we’ll talk about ownership as well as several related features: borrowing, slices, and how Rust lays data out in memory.

July 31, 2025 · 1 min · Kristian Alexander P

rust resources

Rust free and online resources Links https://www.youtube.com/@letsgetrusty

July 31, 2025 · 1 min · Kristian Alexander P

rust variables

Immutable By default rust variables are immutable. Once a value is bound to a name, you can’t change that value. We can make a mutable variable using the keyword mut. fn main() { let mut x = 5; println!("The value of x is: {x}"); x = 6; println!("The value of x is: {x}"); } The value of x is: 5 The value of x is: 6 Constant. Like immutable variables, constants are values that are bound to a name and are not allowed to change, but there are a few differences between constants and variables. First, you aren’t allowed to use mut with constants. Constants aren’t just immutable by default—they’re always immutable. You declare constants using the const keyword instead of the let keyword, and the type of the value must be annotated. We’ll cover types and type annotations in the next section, “Data Types”, so don’t worry about the details right now. Just know that you must always annotate the type. ...

July 31, 2025 · 3 min · Kristian Alexander P

perfect-number

What is perfect number? In number theory, a perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For instance, 6 has divisors 1, 2 and 3 (excluding itself), and 1 + 2 + 3 = 6, so 6 is a perfect number. The next perfect number is 28, since 1 + 2 + 4 + 7 + 14 = 28. ...

March 14, 2024 · 1 min · Kristian Alexander P

python script examples

Example python scripts archlinux packages import subprocess def packages_list(): """Yay packages list""" packages = subprocess.run(["yay", "-Qu"], capture_output=True, text=True) if packages.stdout: return packages.stdout else: return "all packages updated!" return packages_list() get the wireless interface import subprocess import re def get_wlan_iface(): """Get the wireless interface name.""" interfaces = subprocess.run( ["ip", "link", "show"], capture_output=True, text=True ) pattern = r"(^\d+:\s+)(wl.+):" for iface in interfaces.stdout.splitlines(): if re.search(pattern, iface): match = re.search(pattern, iface) assert match is not None return match.group(2) return get_wlan_iface()

March 14, 2024 · 1 min · Kristian Alexander P

rust hello world

Hello world The basic hello world in Rust. fn main() { // Statements here are executed when the compiled binary is called. // Print text to the console. println!("Hello World!"); } Backlinks rustup

February 25, 2024 · 1 min · Kristian Alexander P

rustup

Install rust Get the installer script here for linux, but also support other os’es like windows. In archlinux, using rustup is the recommended way to install if you intend to program anything in Rust.

February 25, 2024 · 1 min · Kristian Alexander P