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-0.20.11/tests/split_declaration.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

68 lines
1.6 KiB
Rust

//! When input is split across multiple attributes on one element,
//! darling should collapse that into one struct.
use darling::{Error, FromDeriveInput};
use syn::parse_quote;
#[derive(Debug, FromDeriveInput, PartialEq, Eq)]
#[darling(attributes(split))]
struct Lorem {
foo: String,
bar: bool,
}
#[test]
fn split_attributes_accrue_to_instance() {
let di = parse_quote! {
#[split(foo = "Hello")]
#[split(bar)]
pub struct Foo;
};
let parsed = Lorem::from_derive_input(&di).unwrap();
assert_eq!(
parsed,
Lorem {
foo: "Hello".to_string(),
bar: true,
}
);
}
#[test]
fn duplicates_across_split_attrs_error() {
let di = parse_quote! {
#[split(foo = "Hello")]
#[split(foo = "World", bar)]
pub struct Foo;
};
let pr = Lorem::from_derive_input(&di).unwrap_err();
assert!(pr.has_span());
assert_eq!(pr.to_string(), Error::duplicate_field("foo").to_string());
}
#[test]
fn multiple_errors_accrue_to_instance() {
let di = parse_quote! {
#[split(foo = "Hello")]
#[split(foo = "World")]
pub struct Foo;
};
let pr = Lorem::from_derive_input(&di);
let err: Error = pr.unwrap_err();
assert_eq!(2, err.len());
let mut errs = err.into_iter().peekable();
assert_eq!(
errs.peek().unwrap().to_string(),
Error::duplicate_field("foo").to_string()
);
assert!(errs.next().unwrap().has_span());
assert_eq!(
errs.next().unwrap().to_string(),
Error::missing_field("bar").to_string()
);
assert!(errs.next().is_none());
}