Skip to content

Commit 9ae80b8

Browse files
committed
fixup
Signed-off-by: tison <wander4096@gmail.com>
1 parent 22f984c commit 9ae80b8

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

diagnostics/task-local/src/lib.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ use std::task::Poll;
3535

3636
use logforth_core::Diagnostic;
3737
use logforth_core::Error;
38-
use logforth_core::kv::{KeyOwned, ValueOwned};
39-
use logforth_core::kv::{KeyView, ValueView, Visitor};
38+
use logforth_core::kv::KeyOwned;
39+
use logforth_core::kv::ValueOwned;
40+
use logforth_core::kv::Visitor;
4041

4142
thread_local! {
42-
static TASK_LOCAL_MAP: RefCell<Vec<(KeyView<'_>, ValueView<'_>)>> = const { RefCell::new(Vec::new()) };
43+
static TASK_LOCAL_MAP: RefCell<Vec<(KeyOwned, ValueOwned)>> = const { RefCell::new(Vec::new()) };
4344
}
4445

4546
/// A diagnostic that stores key-value pairs in a task-local context.
@@ -54,7 +55,7 @@ impl Diagnostic for TaskLocalDiagnostic {
5455
TASK_LOCAL_MAP.with(|map| {
5556
let map = map.borrow();
5657
for (key, value) in map.iter() {
57-
visitor.visit(*key, *value)?;
58+
visitor.visit(key.view(), value.view())?;
5859
}
5960
Ok(())
6061
})
@@ -114,17 +115,14 @@ impl<F: Future> Future for TaskLocalFuture<F> {
114115
TASK_LOCAL_MAP.with(|map| {
115116
let mut map = map.borrow_mut();
116117
for (key, value) in this.context.iter() {
117-
map.push((key.view(), value.view()));
118+
map.push((key.clone(), value.clone()));
118119
}
119120
});
120121

121122
let n = this.context.len();
122123
let guard = Guard { n };
123124

124-
let result = match future.poll(cx) {
125-
Poll::Ready(output) => Poll::Ready(output),
126-
Poll::Pending => Poll::Pending,
127-
};
125+
let result = future.poll(cx);
128126

129127
drop(guard);
130128
result

layouts/google-cloud-logging/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl Visitor for KvCollector<'_> {
152152
}
153153
}
154154

155-
let value = match serde_json::to_value(&value) {
155+
let value = match serde_json::to_value(value) {
156156
Ok(value) => value,
157157
Err(_) => value.to_string().into(),
158158
};

layouts/json/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ struct KvCollector<'a> {
113113
impl Visitor for KvCollector<'_> {
114114
fn visit(&mut self, key: KeyView, value: ValueView) -> Result<(), Error> {
115115
let key = key.to_string();
116-
match serde_json::to_value(&value) {
116+
match serde_json::to_value(value) {
117117
Ok(value) => self.kvs.insert(key, value),
118118
Err(_) => self.kvs.insert(key, value.to_string().into()),
119119
};

0 commit comments

Comments
 (0)