Skip Navigation

Posts
0
Comments
49
Joined
6 mo. ago

  • Not really, because rust doesn't have exceptions. Instead you are encouraged to handle every possible case with pattern matching. For example:

     rust
        
    fn maybe_add_one(number: Option<u8>) -> u8 {
        match number {
            None => 0,
            Some(i) => i + 1,
        }
    }
    
      

    Option

    <u8>

    is a type which can either be some 8bit unsigned integer, or none. It's conceptually similar to a Nullable<int> in C#.

    In C# you could correctly implement this like:

     csharp
        
    public int MaybeAddOne(int? number)
    {
        if (number.HasValue)
        {
            return number.Value + 1;
        }
    
        return 0;
    } 
    
      

    In rust, you can call Unwrap on an option to get the underlying value, but it will panic if the value is None (because None isn't a u8):

     rust
        
    fn maybe_add_one(number: Option<u8>) -> u8 {
        number.unwrap() + 1
    }
    
      

    In some cases unwrap could be useful if you don't care about a panic or if you know the value can't be None. Sometimes it's just used as a shortcut. You can likewise do this in C#:

     csharp
        
    public int MaybeAddOne(int? number)
    {
        return number.Value + 1;
    } 
    
      

    But this throws an exception if number is null.

    A panic isn't the same as an exception though, you can't 'catch' a panic, it's unrecoverable and the program will terminate more-or-less immediately.

    Rust provides a generic type Result<T, E>, T being a successful result and E being some error type, which you are encouraged to use along with pattern matching to make sure all cases are handled.

  • Yes it is. Typically you'd do some pattern matching to handle every possible case, but Unwrap is often used as a shortcut.

  • It's more like a method that can throw an exception. Rust doesn't really have exceptions, but if you have a Result

    <T>

    or Option

    <T>

    type you can Unwrap it to get just the T. But if there's no T to get (in the case of an Error type for Result for None for Option) the call panics.

  • Leto II Atreides

  • I don't know why, but if I had to guess, because it was easier to get the amendment to the city charter passed if they excluded the general election. Once they prove it works maybe it will be easier to expand the scope.

    I haven't heard him mention it, but I bet he would be in favor of it.

  • Only in the primary, not in the general election.

  • If Mamdani doesn't win this election I am going to crash the fuck out.

  • Well no, the Canonical distribution is Ubuntu.

    /s

  • Smöl

    Jump
  • Rotifers are multicellular animals and have organs, and they are a lot smaller than this. Maybe not as cute though.

  • For 98% of Dems (the politicians, I mean--I don't think the percentage is as high among the general population) being weak ass babies is what they want. "Norms and traditions" is their ideology.

  • My favorite Master System memory is playing Double Dragon with my dad.

  • Deleted

    Permanently Deleted

    Jump
  • What do you mean? People love barbeque sauce. There's nothing more normal and human than barbeque sauce. Biological human beings are natural barbeque sauce enthusiasts.

  • And she's already being primaried by her own lieutenant governor, who's focused on some of the same issues as Mamdani.

  • There aren't really any ways to remove SC justices in the law. Thats exactly why we on the left have been raising concern about these appointees for so long.

    Well, they can hypothetically be impeached, but that's unlikely to happen with the current Congress.

  • For wayland applications you can try waypipe too, which I've found works for most things.

  • Deleted

    Permanently Deleted

    Jump
  • Cellular peptide cake with mint frosting

  • Yes, it does guarantee that. But you're still going to be in jail for weeks to months until your trial is concluded. Many people have been held for years in pretrial detention before being released.

    How long would your job keep you on payroll if you were arrested and held in jail? How long would you be able to pay rent or provide for your children? Even a few weeks is enough to be devastating to most people.

    In 2019 the average pretrial detention for felonies in New York State was 10 months.

  • There should be no chance of bail for crimes against children

    I am not saying I have a better solution, but how long do you think it would take for such a rule to be used to lock up trans people or drag queens?

  • I agree that the bail system is bad (both practically and morally).

    To be clear though, people on bail have not yet been demonstrated in court to be guilty of the crimes they've been accused of. I don't think locking up anyone accused of a crime while they await trial (which could be years) is an improvement.

  • Goals.

    Jump
  • These are some of the closest relatives of the vertebrates, by the way.