Skip Navigation

Carl [he/him]

@ Carl @hexbear.net

Posts
27
Comments
2302
Joined
1 yr. ago

  • you can't use that function on a string, you have to convert to a vector!

    you can't use that function on a vector, you have to convert to a string!

    I HATE STRING OPERATIONS IN RUST I HATE STRING OPERATIONS IN RUST

  • he says primaries and midterms, and to make sure you have registered to be able to vote in both. i don't remember if he says who you should vote for in the primaries.

  • lift kit? no, I'll be making a lowering kit and a hatchback-style roof.

  • I would 100% buy a slate truck to replace my car, only thing is I'm gonna be driving my car until it disintegrates so

  • Technology Connections starts ranting

    "That's why you need to vote for Democrats!"

  • Zebra!

  • i practiced whiteboarding today. never done that before. learned the hard way that i'm still terrible at coding.

  • the famed urbuntu'u gauntlet-smiths made their masterwork gauntlets for the wealthiest clients, which looked exactly like cheap 1970s leather

  • Fun experiment with Rust

     
        
    struct Dropper(i32);
    // dropper object announces when it is dropped by Rust
    impl Drop for Dropper {
        fn drop(&mut self) {
            println!("Dropping value {}", self.0);
        }
    }
    
    #[allow(unused_assignments)] // added to suppress compiler warning
    fn main() {
        // we'll use these variables to reaccess a "dropped" memory address and value
        let mut old_addr: usize = 0;
        let mut old_value: i32 = 0;
    
        {
            // we'll create and then shadow the same variable multiple times, and see how Rust handles memory assignment
            let x = Dropper(1);
            println!("Created x = {}", x.0);
            println!("address: {:p}", &x);
            // we'll save these for later
            old_addr = &x as *const Dropper as usize;
            old_value = x.0;
            
            let x = Dropper(2);
            println!("Shadowed x = {}", x.0);
            println!("address: {:p}", &x);
            
            let x = Dropper(3);
            println!("Shadowed x again = {}", x.0);
            println!("address: {:p}", &x);
            
            println!("End of inner block");
        }
        println!("All should be dropped now");
        println!("Testing reading first memory address.");
        
        unsafe {
            // now we're going to read back the dropped first value we created with unsafe Rust
            let raw_ptr = old_addr as *const i32;
            let value_at_old_addr = *raw_ptr;
            
            println!("Original value was: {}", old_value);
            println!("Value at old address: {}", value_at_old_addr);
            println!("Same? {}", old_value == value_at_old_addr);
        }
    }
    
      

     
        
    Created x = 1
    address: 0x7fffdb3f2f8c
    Shadowed x = 2
    address: 0x7fffdb3f303c
    Shadowed x again = 3
    address: 0x7fffdb3f30ec
    End of inner block
    Dropping value 3
    Dropping value 2
    Dropping value 1
    All should be dropped now
    Testing reading first memory address.
    Original value was: 1
    Value at old address: 1
    Same? true
    
      
  • According to Know Your Meme, there is no online reference to either of these names prior to the original tweet of this meme, which seems to indicate that it is a doctored screenshot and not a real mistake by Gemini's AI Overview.

  • Chapter 2 of the Rust Book... with a twist!

  • this post is a bit

  • Yes. Without the label I would break out of the current layer of the loop only, and the higher layer of the loop would continue even though the search has completed successfully. In this case it wouldn't actually break anything since the found tag already got set, but if you had a huge data set it would be really inefficient to keep iterating through it after finding the thing you wanted.

  • reminder that when they liberated Paris De Gaulle decided that the actual French colonial troops that had beaten the Nazis weren't white enough and swapped them out for members of the French Resistance and other predominantly white formations for the propoganda reels.

    Not for nothing but that's also the reason why the US action in Italy doesn't get nearly as much play as the action in France and elsewhere - because they'd have to show the black and Japanese-American units if they made a movie about that part of the war.

  • That was fun because it was the most incoherent markov chain stuff with a bit of randomization, so you'd be able to read the "personality" of each subreddit by the words that it used the most often.

    Now it's just slop.

  • I'd send him a counter offer at a more reasonable price. You never know, maybe he just needs a reality check.

  • Today's discussion of Lemmy and piefed made me want to learn the basics of Rust

    I guess carcinization also applies to lefty software devs

     
        
    fn main() {
        counttoten();
        countdown();
        timestables();
        find_target(create_grid(5, 5), 50);
        find_target(create_grid(10, 10), 50);
    }
    
    fn counttoten() {
        let mut x: i32 = 1;
        loop {
            println!("Counting to ten!  {x}");
            x += 1;
            if x > 10 {
                break
            }
        }
    }
    
    fn countdown() {
        let mut x: i32 = 10;
        while x > 0 {
            println!("Counting Down!  {x}");
            x -= 1;
        }
    }
    
    fn timestables() {
        for x in 1..=3 {
            for y in 1..=3 {
                let z: i32 = x * y;
                println!("{x} times {y} is {z}")
            }
        }
    }
    
    fn find_target(grid: Vec<Vec<i32>>, target: i32) -> bool {
        let mut found = false;
        'search: for row in grid {
            for value in row {
                if value == target {
                    println!("Found {target}!");
                    found = true;
                    break 'search;                
                }
            }
        }
            
        if found {
            true
        } else {
            println!("Did not find {target}.");
            false
        }
    }
    
    fn create_grid(rows: usize, cols: usize) -> Vec<Vec<i32>> {
        let mut grid = Vec::new();
        let mut gridcounter = 1;
    
        for _ in 0..rows {
            let mut row = Vec::new();
            for _ in 0..cols {
                row.push(gridcounter);
                gridcounter += 1;
            }
            grid.push(row);
        }
    
        grid
    }
    
      
  • idk those sorts of slapdash, half baked filters are probably exactly the sorts of things i'd make if i was programming a social media site so