Skip to content

Commit

Permalink
Oh, egads! My data structure is ruined!
Browse files Browse the repository at this point in the history
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 serde-rs/serde#1504. Alias and name should be swapped once the issue is fixed. Also I forgot to make a field public for some reason.
  • Loading branch information
Morgan Arnold committed Jan 9, 2022
1 parent f42157f commit ae1eb3b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lichess/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Title>,
#[serde(default)]
Expand Down Expand Up @@ -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>,
Expand Down

0 comments on commit ae1eb3b

Please sign in to comment.