Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum Type {
- Visa,
- Discover,
- MasterCard,
- AmericanExpress
- }
- impl ToString for Type {
- fn to_string(&self) -> String {
- match self {
- Type::Visa => "Visa".into(),
- Type::Discover => "Discover".into(),
- Type::MasterCard => "MasterCard".into(),
- Type::AmericanExpress => "AmericanExpress".into(),
- }
- }
- }
- type Rule = (Type, Vec<Vec<String>>);
- const RULES: Vec<Rule> = vec![
- (Type::Visa, vec![vec!["4"]]),
- (Type::Discover, vec![vec!["6011"], range_of_strings(622126, 622925), range_of_strings(644, 649), ["65"]]),
- (Type::MasterCard, vec![range_of_strings(50, 55), range_of_strings(222100, 272099)]),
- (Type::AmericanExpress, vec![vec!["34"], vec!["37"]]),
- ];
- fn range_of_strings(start: u32, end: u32) -> Vec<String> {
- (start..=end).map(|n| n.to_string()).collect()
- }
- fn card_matches_rule(card: String, rule: Rule) -> boolean {
- }
- fn to_matching_type(card: String, matched: Option<Type>, type: Type) -> Option<Type> {
- }
- fn detect_type(card: Option<String>) -> Maybe<Type> {
- return if card.is_none() { card } else {
- }
- }
- fn main() {
- println!("Hello, world!");
- }
Add Comment
Please, Sign In to add comment