Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup chat boxing #3

Open
wants to merge 1 commit into
base: 0.2.1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Chat {
}
}

pub fn siblings(&self) -> &Vec<BoxedChat> {
pub fn siblings(&self) -> &Vec<Chat> {
&self.base().extra
}

Expand Down Expand Up @@ -215,7 +215,7 @@ impl TraditionalParser {
if n_components > 0 {
top_level.base.extra.extend(
self.done.into_iter()
.map(move |component| Chat::Text(component).boxed()));
.map(move |component| Chat::Text(component)));
}

Chat::Text(top_level)
Expand Down Expand Up @@ -268,7 +268,7 @@ pub struct BaseComponent {
#[serde(skip_serializing_if = "Option::is_none")]
pub hover_event: Option<ChatHoverEvent>,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub extra: Vec<BoxedChat>,
pub extra: Vec<Chat>,
}

fn should_skip_flag_field(flag: &bool) -> bool {
Expand Down Expand Up @@ -299,7 +299,7 @@ impl Into<BaseComponent> for JsonComponentBase {
insertion: self.insertion,
click_event: self.click_event,
hover_event: self.hover_event,
extra: self.extra.into_iter().map(move |elem| elem.boxed()).collect(),
extra: self.extra,
}
}
}
Expand Down Expand Up @@ -367,7 +367,7 @@ impl TextComponent {

let mut last_had_formatters = has_formatters;
for extra in b.extra.iter() {
if let Chat::Text(child) = extra.as_ref() {
if let Chat::Text(child) = extra {
match child.traditional_formatters(last_had_formatters) {
Some(child_fmts) => {
last_had_formatters = true;
Expand Down Expand Up @@ -425,7 +425,7 @@ impl TextComponent {
pub struct TranslationComponent {
pub translate: String,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub with: Vec<BoxedChat>,
pub with: Vec<Chat>,

#[serde(flatten)]
#[serde(skip_deserializing)]
Expand Down Expand Up @@ -887,8 +887,7 @@ impl<'de> Deserialize<'de> for Chat {
for with in withs {
withs_out.push(with.deserialize_any(V)
.map_err(move |err| M::Error::custom(
format!("unable to parse one of the translation with entries :: {}", err)))?
.boxed());
format!("unable to parse one of the translation with entries :: {}", err)))?);
}
Ok(Chat::Translation(TranslationComponent{
base: base.into(),
Expand Down Expand Up @@ -1044,11 +1043,11 @@ pub mod tests {
b.color = Some(ColorCode::Red);
b
},
}).boxed(),
}),
Chat::Text(TextComponent{
text: "this is ".to_owned(),
base: BaseComponent::default(),
}).boxed(),
}),
Chat::Text(TextComponent{
text: "yellow".to_owned(),
base: {
Expand All @@ -1057,7 +1056,7 @@ pub mod tests {
b.bold = true;
b
}
}).boxed()
})
);
b
}
Expand Down