Skip to content

Commit 374a14a

Browse files
committed
feat: v6.0.1
1 parent 1adb853 commit 374a14a

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tcplane"
3-
version = "6.0.0"
3+
version = "6.0.1"
44
readme = "README.md"
55
edition = "2024"
66
authors = ["root@ltpp.vip"]

src/context/impl.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,14 +405,15 @@ impl Context {
405405
///
406406
/// # Arguments
407407
///
408-
/// - `impl AsRef<str>` - The key for the data.
408+
/// - `AsRef<str>` - The key for the data.
409409
///
410410
/// # Returns
411411
///
412412
/// - `Option<V>` - The data value if found and successfully downcasted, otherwise `None`.
413-
pub async fn try_get_data<V>(&self, key: impl AsRef<str>) -> Option<V>
413+
pub async fn try_get_data<V, K>(&self, key: K) -> Option<V>
414414
where
415415
V: Any + Send + Sync + Clone,
416+
K: AsRef<str>,
416417
{
417418
self.read()
418419
.await
@@ -426,7 +427,7 @@ impl Context {
426427
///
427428
/// # Arguments
428429
///
429-
/// - `impl AsRef<str>` - The key for the data.
430+
/// - `AsRef<str>` - The key for the data.
430431
///
431432
/// # Returns
432433
///
@@ -435,9 +436,10 @@ impl Context {
435436
/// # Panics
436437
///
437438
/// Panics if the data is not found or cannot be downcasted.
438-
pub async fn get_data_value<V>(&self, key: impl AsRef<str>) -> V
439+
pub async fn get_data_value<V, K>(&self, key: K) -> V
439440
where
440441
V: Any + Send + Sync + Clone,
442+
K: AsRef<str>,
441443
{
442444
self.try_get_data(key).await.unwrap()
443445
}
@@ -446,7 +448,7 @@ impl Context {
446448
///
447449
/// # Arguments
448450
///
449-
/// - `impl AsRef<str>` - The key of the data to remove.
451+
/// - `AsRef<str>` - The key of the data to remove.
450452
///
451453
/// # Returns
452454
///

src/response/impl.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ impl Response {
66
///
77
/// # Arguments
88
///
9-
/// - `T` - Data that can be converted into ResponseData.
9+
/// - `Into<ResponseData>` - Data that can be converted into ResponseData.
1010
///
1111
/// # Returns
1212
///
1313
/// - `Self` - A new Response instance.
14-
pub fn from<T: Into<ResponseData>>(data: T) -> Self {
14+
pub fn from<T>(data: T) -> Self
15+
where
16+
T: Into<ResponseData>,
17+
{
1518
Self(data.into())
1619
}
1720

@@ -37,12 +40,15 @@ impl Response {
3740
///
3841
/// # Arguments
3942
///
40-
/// - `T` - Data that can be converted into ResponseData.
43+
/// - `Into<ResponseData>` - Data that can be converted into ResponseData.
4144
///
4245
/// # Returns
4346
///
4447
/// - `&mut Self` - Mutable reference to self for method chaining.
45-
pub fn set_data<T: Into<ResponseData>>(&mut self, data: T) -> &mut Self {
48+
pub fn set_data<T>(&mut self, data: T) -> &mut Self
49+
where
50+
T: Into<ResponseData>,
51+
{
4652
self.0 = data.into();
4753
self
4854
}

src/server/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl ServerHook for ErrorHandler {
5050
}
5151

5252
async fn handle(self, ctx: &Context) {
53-
if let Some(error) = ctx.try_get_data::<String>("error").await {
53+
if let Some(error) = ctx.try_get_data::<String, _>("error").await {
5454
eprintln!("{error}");
5555
let _ = std::io::Write::flush(&mut std::io::stderr());
5656
}

0 commit comments

Comments
 (0)