How to match a BigInt?

⚓ Rust    📅 2025-05-01    👤 surdeus    👁️ 5      

surdeus

Warning

This post was published 111 days ago. The information described in this article may have changed.

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: How to match a BigInt?

Label ’b fails. I suspect it's quite simple. I tried different variations, none of them worked - I don't have a plan. Because of this crate I get even more gray hair.

use num_bigint::BigInt;

#[allow(unused_labels, unused_variables)]
fn main() {

    'a: {
        let gizmo = vec![1, 2, 3, 4, 5];

        for i in gizmo {
            match i {
                3 => println!("gotcha!"),
                _ => eprintln!("fuba!"),
            }
        }
        println!();
    }

    'b: {
        let gizmo: Vec<BigInt> = vec![
            BigInt::from(1),
            BigInt::from(2),
            BigInt::from(3),
            BigInt::from(4),
            BigInt::from(3),
        ];
        // for i in gizmo {                                                                      
        //     match i {                                                                         
        //         3 => println!("gotcha!"),                                                     
        //         _ => eprintln!("fuba!"),                                                      
        //     }                                                                                 
        // }                                                                                     
        // println!();                                                                           
    }
}
            

(Playground)

4 posts - 3 participants

Read full topic

🏷️ rust_feed