Avatar
shymeander
34a9714f4a02a4839825dc65afbbc338b48af83f0104a96e438a28a21d66a8ff

nostr:npub1sg6plzptd64u62a878hep2kev88swjh3tw00gjsfl8f237lmu63q0uf63m https://github.com/1wErt3r/billy Billy: Your Bitcoin Node Assistant 🧚‍♂️

// src/main.rs

use derive_builder::Builder;

#[derive(Builder)]

struct BigBoss {

name: String,

rank: String,

alias: Option,

birth_date: String,

}

fn main() {

let mister_rabbit = BigBoss::builder()

.name("Big Boss".into())

// Big Boss is a Commander in the military

.rank("Commander".into())

// Big Boss has an alternate name "Mister Rabbit"

.alias(Some("Mister Rabbit".into()))

.birth_date("1970-05-05".into())

.build()

.unwrap();

println!("{:?}", mister_rabbit);

}

```rust

fn main() {

// Variables (immutable by default)

let x = 5;

let mut y = 1; // mutable

// Types

let i: i32 = 42; // integers

let f: f64 = 3.14; // float

let b: bool = true;

let s: String = String::from("hello");

let slice: &str = "world";

// Vec (dynamic array)

let mut v: Vec = vec![1, 2, 3];

v.push(4);

// Ownership & Borrowing

let s1 = String::from("mine");

let s2 = &s1; // borrow (reference)

println!("{} {}", s1, s2);

// Pattern Matching

match x {

1 => println!("one"),

2..=5 => println!("2-5"),

_ => println!("other"),

}

// Option & Result for safety

let opt: Option = Some(42);

if let Some(n) = opt {

println!("{}", n);

}

// Structs & Impl

struct Point { x: i32, y: i32 }

impl Point {

fn new(x: i32, y: i32) -> Self {

Point { x, y }

}

}

// Traits (interfaces)

trait Shape {

fn area(&self) -> f64;

}

// Closures

let add = |a, b| a + b;

// Iterators

let sum: i32 = (1..=5).sum();

}

```

https://github.com/1wErt3r/hyper-uppercut Building this bot to learn rust and #nostr

https://github.com/1wErt3r/nostrsss I'm learning Rust with nostr. Is ENV heavy config like this annoying?