Extracting value from an enum (more thoughts)

⚓ rust    📅 2025-05-30    👤 surdeus    👁️ 2      

surdeus

Strange, I thought it's trivial in Rust, but I do not see how. I have an enum with about ten cases. I know that I have a particular case and I want to get its value. But I do not see any way doing that except match.

                              match out.get("name") {
                                Some(name) if matches!(name, Text(_)) => match name {
                                    Text(val) => val,
                                    _ => unreachable!(),
                                },
                                _ => "simhttp-${0}"
                            }

Can we close the topic?

3 posts - 2 participants

Read full topic

🏷️ rust_feed