This repository has been archived on 2026-08-31. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
donglora/vendor/darling/tests/from_variant.rs
T
swaitsandClaude Opus 4.6 3102fc747a feat: add display UI with splash screen, dashboard, and RSSI sparkline
Implement full SSD1306 OLED display support:
- Splash screen on boot (1.5s) with project name, version, board
- Dashboard showing radio state, config, counters, RSSI/SNR
- RSSI history sparkline (64-sample ring buffer, 2px-wide bars)
- DisplayOn/DisplayOff host commands routed via dedicated channel
- Pure render functions against generic DrawTarget (no hardware coupling)
- Display on/off control bypasses radio task entirely

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 20:42:54 -06:00

58 lines
1.3 KiB
Rust

use darling::FromVariant;
use syn::{spanned::Spanned, Expr, ExprLit, LitInt};
#[derive(FromVariant)]
#[darling(from_ident, attributes(hello))]
#[allow(dead_code)]
pub struct Lorem {
ident: syn::Ident,
into: Option<bool>,
skip: Option<bool>,
discriminant: Option<syn::Expr>,
fields: darling::ast::Fields<syn::Type>,
}
impl From<syn::Ident> for Lorem {
fn from(ident: syn::Ident) -> Self {
Lorem {
ident,
into: Default::default(),
skip: Default::default(),
discriminant: None,
fields: darling::ast::Style::Unit.into(),
}
}
}
#[test]
fn discriminant() {
let input: syn::DeriveInput = syn::parse_str(
r#"
pub enum Test {
Works = 1,
AlsoWorks = 2,
}
"#,
)
.unwrap();
let span = input.span();
if let syn::Data::Enum(enm) = input.data {
let lorem = Lorem::from_variant(
enm.variants
.first()
.expect("Hardcoded input has one variant"),
)
.expect("FromVariant can process the discriminant");
assert_eq!(
lorem.discriminant,
Some(Expr::Lit(ExprLit {
attrs: vec![],
lit: LitInt::new("1", span).into(),
}))
)
} else {
panic!("Data should be enum");
}
}