When I access the item I have to get the first and only one and then unwrap it. I was wondering if there was a way to annotate this to always return the only or just the first item. If there are any others then happy for them to be ignored.
event.invitees.first().unwrap().display_name
I have looked at a deserialization function but wondered if there was a more succinct way with any annotations or anything simpler.
If there will always be exactly one element in the input, you can use a 1-element tuple or array. A tuple is convenient here because you can use dot syntax to get its one field:
I can’t think of a way to ask serde to ignore further elements other than by customizing the deserialization with impl Deserialize for... or #[serde(from)]. But, you can write event.invitees[0] in place of .first().unwrap(). Note that either of these will panic if the input has zero elements.