From ae1eb3b82403192d14b56289dd6df174583eb7b1 Mon Sep 17 00:00:00 2001 From: Morgan Arnold Date: Sat, 8 Jan 2022 20:06:53 -0800 Subject: [PATCH] Oh, egads! My data structure is ruined! But what if... I were to rename the "name" field to "username" so that I can use it for Top10s and disguise it as "name" using an alias? Delightfully devilish, Seymour... Hacky fix to get around https://github.com/serde-rs/serde/issues/1504. Alias and name should be swapped once the issue is fixed. Also I forgot to make a field public for some reason. --- src/lichess/user.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lichess/user.rs b/src/lichess/user.rs index ebf2756..1ffbde8 100644 --- a/src/lichess/user.rs +++ b/src/lichess/user.rs @@ -14,7 +14,8 @@ use chrono::serde::ts_milliseconds; #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "camelCase")] pub struct LightUser { - pub name: String, + #[serde(alias = "name")] + pub username: String, #[serde(default)] pub title: Option, #[serde(default)] @@ -83,7 +84,7 @@ pub struct ExtendedUser { pub verified: bool, pub play_time: PlayTime, #[serde(default)] - title: Option<Title>, + pub title: Option<Title>, pub url: String, #[serde(default)] pub playing: Option<String>,