Skip Navigation
Is anyone else having trouble giving up Reddit due to content?
  • I deleted my 14 year old reddit account when they pulled their shit. Then I recently created a new account because I need to be able to get answers to specific programming questions sometimes, and lemmy doesn't have the population of users that reddit still has. I generally post on both lemmy and reddit, but I almost always get more answers on reddit.

  • How can I create a mutable vector singleton?
  • Ah I didn't realize most people have moved onto OnceCell. The issue with both lazy static and oncecell is that they can only be assigned to once. You need a global mutable state, so neither OnceCell or lazy_static are the right choice.

    You're going to be fighting the borrow checker if you try to have global mutable state. It will bite you eventually. You can potentially use an interior mutablity pattern along with a mutex. Have you looked into interior mutability?

  • What is going on with serde?
  • I get why the binary is there, but there really should be a simple way to force compilation instead of downloading a precompiled binary.

    Serde is incredible though, so it can get away with basically anything it wants.

  • What is the best memory model for a Tic Tac Toe grid? (References and ownership)
  • Ideally, all of these values should be represented in memory exactly the same way:

    That would make the game hard to play, since you'd have to think about where your move would end up since it won't stay on the cell you click.

    I think you're wanting to store them that way so that you can easily check for win conditions, maybe? But that's the wrong approach. Store the cells as they appear to the player, in a 2d Array (or 1d Array with indexing math. That's how I'd do it).

    Then you can take advantage of symmetries in your win condition code, if you like. But it really couldn't be much simpler than counting the matching cells in each row, column, and diagonal. That's just 8 groups of 3.

  • how would you opt to wall mount this?
  • If you can only hit one stud, you should hit it in two places vertically if possible. Bottom shelf and top shelf if you can. You can still add some anchors if you need, but that works for most things. I hang cabinets into single studs all the time just by screwing it in two spots. It will work as long as the shelf or cabinet is built well enough.

  • how would you opt to wall mount this?
  • If those hooks on the top corners are a multiple of 16" apart, and they line up with studs, you could use some 2-3" screws through those into studs.

    If they don't line up with studs, you could stain a piece of lumber close to the same color and screw it to the wall through the studs and screw the shelf down to that board. It would act as a ledge for one of the shelves to sit on.

    There's no back so there's no easy way to directly screw this shelf to the wall. You'll have to get creative.

    You could find the studs and put screws angled through one of the shelves into the studs. Screw from underneath the shelf if it's lower than eye level, above the shelf if it's above eye level. This is so you don't see the screws.

    You could get realy fancy and use a pocket hole jig to make nice holes for your angled screws.

  • inconsistent documentation for iced-rs

    Im trying to use iced for the gui in an audio plug in I'm building, but I keep seeing discrepancies in how to accomplish this.

    On the iced github page, it says that to implement the Sandbox trait, you use this signature: fn view(&self), yet in the documentation it says to use view(&mut self). When I try to use the non-mut version, I get an error saying that it expects self to be mutable.

    I also stumbled across iced-pure, which seems like a better idea. But I need to use a NumberInput widget from the iced-aw crate. Unfortunately, these widgets are not pure.

    So how do I go about creating a gui using NumberInput? Do I need to create the widgets myself to make them pure? I'd like to use other widgets from the iced-aw crate too, so that wouldn't be ideal

    Or do i have to use the mutable version of view? If so, why does github say to use non mutable? Is this specific to certain versions of iced? If the newer version of iced uses a non mutable view function, does that mean it's pure? Have the iced-pure changes been merged into iced?

    11
    Inconsistent documentation for iced-rs

    Im trying to use iced for the gui in an audio plug in I'm building, but I keep seeing discrepancies in how to accomplish this.

    On the iced github page, it says that to implement the Sandbox trait, you use this signature: fn view(&self), yet in the documentation it says to use view(&mut self). When I try to use the non-mut version, I get an error saying that it expects self to be mutable.

    I also stumbled across iced-pure, which seems like a better idea. But I need to use a NumberInput widget from the iced-aw crate. Unfortunately, these widgets are not pure.

    So how do I go about creating a gui using NumberInput? Do I need to create the widgets myself to make them pure? I'd like to use other widgets from the iced-aw crate too, so that wouldn't be ideal

    Or do i have to use the mutable version of view? If so, why does github say to use non mutable? Is this specific to certain versions of iced? If the newer version of iced uses a non mutable view function, does that mean it's pure? Have the iced-pure changes been merged into iced?

    5
    Why do i see mostly posts from a single community?

    I've subscribed to a handful of communities, but my feed is almost exclusively from this asklemmy. How can I see more from other communities?

    13
    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/)BA
    Barbacamanitu @lemmy.world
    Posts 3
    Comments 101