Skip to content

Commit e752e70

Browse files
committed
update toasty to support cow<str>
1 parent a575e9f commit e752e70

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

frameworks/Rust/xitca-web/Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/Rust/xitca-web/src/ser.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![allow(dead_code)]
22

3+
use std::borrow::Cow;
4+
35
use serde::{Deserialize, Deserializer, Serialize, Serializer, ser::SerializeStruct};
46
use xitca_http::{
57
body::Once,
@@ -54,27 +56,12 @@ impl World {
5456
pub struct Fortune {
5557
#[cfg_attr(feature = "toasty", key)]
5658
pub id: i32,
57-
#[cfg(not(feature = "toasty"))]
58-
pub message: std::borrow::Cow<'static, str>,
59-
#[cfg(feature = "toasty")]
60-
pub message: String,
61-
}
62-
63-
#[cfg(not(feature = "toasty"))]
64-
impl Fortune {
65-
#[inline]
66-
pub fn new(id: i32, message: impl Into<std::borrow::Cow<'static, str>>) -> Self {
67-
Self {
68-
id,
69-
message: message.into(),
70-
}
71-
}
59+
pub message: Cow<'static, str>,
7260
}
7361

74-
#[cfg(feature = "toasty")]
7562
impl Fortune {
7663
#[inline]
77-
pub fn new(id: i32, message: impl Into<String>) -> Self {
64+
pub fn new(id: i32, message: impl Into<Cow<'static, str>>) -> Self {
7865
Self {
7966
id,
8067
message: message.into(),

0 commit comments

Comments
 (0)