Skip Navigation
InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)LI
Posts
0
Comments
145
Joined
2 yr. ago
  • I leave mine in the trunk and have only walked into the store without them twice. Not forgetting them before walking into the store and putting them back into the trunk after unloading them is the hardest part.

  • Basically, you can generalize your trait types into their parent (super) traits for situations when functionality is specific to those supertrait objects.

    As an example, if you have a trait CanBark and it is a super trait for the trait IsDog, you can coerce your references of &dyn IsDog into a &dyn CanBark. You can then work with other trait types that share a super trait.

     undefined
        
    trait CanBark {
        fn bark(&self);
    }
    trait IsSeal: CanBark { }
    trait IsDog: CanBark { }
    
    fn bark_as_group(barkers: &Vec<&dyn CanBark>) {
        for barker in barkers {
            barker.bark();
        }
    }
    
    let spot: &dyn IsDog = get_spot();
    let seal: &dyn IsSeal = get_seal();
    let barkers: Vec<&dyn CanBark> = Vec::new();
    barkers.push(spot);  // coerced
    barkers.push(seal);  // coerced
    bark_as_group(&barkers);
    
      

    At least, I hope this is possible now. If it's purely "you can return a coerced type from a function", that is less useful.

  • When I learned Python I thought that not having a statically typed language was the way to go, but then it just became an issue when I was trying to ensure that everything was at least something like what I was expecting. Going back to statically typed languages even harder with Rust has been a dream. I love it.

  • I kept most of my bindings the same as the normal QWERTY keyboard, so I don't have much of an issue swapping between them. I had debated a lot about changing to other keyboard layouts and I'm really glad that I didn't.

  • I've found that one of the best things to do when making a library for something that is going to have a web interface is to first have it work in the terminal. You can much more quickly play around with the design and fix issues there instead of having to work with a more complex web interface.

    You just create a simple menu system, like input("1: Feature A\n2: Feature B\n>") and just start trying out all of the different scenarios and workflows.

  • I had a coworker who would sometimes not create a method as being static to the class and would therefore need to create a default instance to call said method. "It's domain-driven design."

  • There are a few different ways to solve this problem without using unsafe and I'm not sure what would be considered idiomatic. Another option is to ultimately encapsulate all of the nodes in a reference-counted box like Rc or Arc and specify the type of your parent/child/sibling references to the same reference-counted box type. With that, you just share cloned instances around as needed.

    The primary drawback here is that for mutable access you end up having to perform a lock every time on an underlying Mutex (or something similar). You also no longer have direct access to the singular instance of the node.

    There are pros and cons to every approach.

  • One way of solving this is to structure all of your nodes into a HashMap with the node ID as the key and the node type as the value. The underlying node type could have node IDs for referencing purposes. You lose the ability to reference the parent/child/sibling directly, but you avoid direct circular dependencies. That said, now you need to manage dangling references for when the node is removed from the main HashMap collection.

  • For me it all depends on how often a project changes. If it's constantly in flux, I don't bother remembering any of it because I might not be the last one who touched it. The more you try to remember everything, the more wrong you become due to the successive work of your coworkers.

  • There are so many ways to be a hero for those around you. Why end your life when you could dedicate your life to help those in need? When you feel at your lowest, remember that there is someone, right now, who wants to know and believe in you and who hopes that you could do your very best to help them and others.

    This is intended to be motivating. Instead of leaving a hole in the world, you could become a role model for others.