Skip to content

Instantly share code, notes, and snippets.

@Renkai
Created May 11, 2020 15:12
Show Gist options
  • Save Renkai/139e961940d5ebe21b7669376fd24d22 to your computer and use it in GitHub Desktop.
Save Renkai/139e961940d5ebe21b7669376fd24d22 to your computer and use it in GitHub Desktop.
fn encode_spans(rx : CollectorRx) -> impl Iterator<Item = spanpb::Span> {
let finished_spans = rx.collect();
let spans = finished_spans.into_iter().map(|span| {
let mut s = spanpb::Span::default();
s.set_id(span.id.into());
s.set_start(span.elapsed_start);
s.set_end(span.elapsed_end);
s.set_event_id(span.tag);
#[cfg(feature = "prost-codec")]
if let Some(p) = span.parent {
s.parent = Some(spanpb::Parent::ParentValue(p.into()));
} else {
s.parent = Some(spanpb::Parent::ParentNone(true));
};
#[cfg(feature = "protobuf-codec")]
if let Some(p) = span.parent {
s.set_parent_value(p.into());
}
s
});
spans.collect()
}
------
➜ tikv git:(minitrace) ✗ cargo check
Checking tikv_util v0.1.0 (/Users/renkai/renkai-lab/tikv/components/tikv_util)
warning: unused import: `Span`
--> components/tikv_util/src/trace.rs:1:30
|
1 | use minitrace::{CollectorRx, Span};
| ^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0277]: a value of type `impl std::iter::Iterator` cannot be built from an iterator over elements of type `kvproto::protos::span::Span`
--> components/tikv_util/src/trace.rs:39:11
|
39 | spans.collect()
| ^^^^^^^ value of type `impl std::iter::Iterator` cannot be built from `std::iter::Iterator<Item=kvproto::protos::span::Span>`
|
= help: the trait `std::iter::FromIterator<kvproto::protos::span::Span>` is not implemented for `impl std::iter::Iterator`
error[E0720]: opaque type expands to a recursive type
--> components/tikv_util/src/trace.rs:17:38
|
17 | fn encode_spans(rx : CollectorRx) -> impl Iterator<Item = spanpb::Span> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expands to a recursive type
|
= note: type resolves to itself
error: aborting due to 2 previous errors; 1 warning emitted
Some errors have detailed explanations: E0277, E0720.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `tikv_util`.
To learn more, run the command again with --verbose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment