Skip to content

Commit

Permalink
remove Cow
Browse files Browse the repository at this point in the history
  • Loading branch information
wuan committed Jan 4, 2023
1 parent 2afcdda commit 459ba64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,13 +478,13 @@ impl<S: Into<String>> From<S> for EitherSide {

#[derive(PartialEq, Eq, Clone, Debug, Deserialize, Serialize, derive_more::Display)]
#[display(fmt = "{}-{}", "&*_0", "&*_1")]
pub struct ClientVersion(pub Cow<'static, str>, pub Cow<'static, str>);
pub struct ClientVersion(pub String, pub String);

impl ClientVersion {
pub fn new(implementation: Cow<'static, str>, version: Cow<'static, str>) -> Self {
pub fn new(implementation: &str, version: &str) -> Self {
ClientVersion {
0: implementation,
1: version,
0: implementation.to_string(),
1: version.to_string(),
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/server_messages.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{AppID, ClientVersion, Mailbox, Mood, MySide, Nameplate, Phase, TheirSide};
use serde_derive::{Deserialize, Serialize};
use std::{borrow::Cow, collections::HashMap};
use std::{collections::HashMap};

/// Special encoding for the `nameplates` message
#[derive(Serialize, Deserialize, Debug, PartialEq)]
Expand Down Expand Up @@ -187,8 +187,8 @@ impl OutboundMessage {
pub fn bind(appid: AppID, side: MySide) -> Self {
let client_version_string: &str = env!("CARGO_PKG_VERSION");
let client_version = ClientVersion::new(
Cow::Borrowed(CLIENT_NAME),
Cow::Borrowed(client_version_string),
CLIENT_NAME,
client_version_string,
);
OutboundMessage::Bind {
appid,
Expand Down Expand Up @@ -290,7 +290,7 @@ mod test {

#[test]
fn test_client_version_string_rep() {
let client_version = ClientVersion::new(Cow::Borrowed("foo"), Cow::Borrowed("1.0.2"));
let client_version = ClientVersion::new("foo", "1.0.2");

assert_eq!(client_version.to_string(), "foo-1.0.2")
}
Expand Down

0 comments on commit 459ba64

Please sign in to comment.