• 1 Post
  • 25 Comments
Joined 1 year ago
cake
Cake day: August 5th, 2023

help-circle









  • It may be possible to use the Any trait to “launder” the value by first casting it to &Any and then downcasting it to the generic type.

    let any_value = match tmp_value {
        serde_json::Value::Number(x) => x as &Any,
        // ...
    };
    
    let maybe_value = any_value.downcast_ref::< T >();
    

    I haven’t tested it, so I may have missed something.

    Edit: to be clear, this will not actually let you return multiple types, but let the caller decide which type to expect. I assumed this was your goal.





  • Also the Swedish classic “glida in på en räkmacka” ((to) slide in on a shrimp sandwich), which basically means to end up somewhere (location, career, situation) without any difficulties. The shrimp sandwich symbolizes a life without difficulties or in some luxury.

    Then there’s also “halka in på ett bananskal” ((to) slip in on a banana peel), which is similar to the above, but not always favorable and you don’t have any plan or preparation. You just winged it or it just happened by accident.






  • I’m of course only one single anecdotal sample, but the release cadence has probably been the least of my problems. My experience is that it’s fine to not update for quite some time. I have a crate with 1.60 (released about one and a half years ago) as MSRV, which means I run unit tests with that version, as well as stable, beta and nightly. The only pressure to upgrade is that some dependencies are starting to move on. Not that the newer compilers reject my code, not even anything deprecated.

    Also, small, frequent releases usually takes away a lot of the drama around upgrading, in my experience. Not the opposite. A handful of changes are easier to deal with than a whole boatload. Both for the one releasing and for the users.