]>
git.proxmox.com Git - rustc.git/blob - src/librustc_metadata/isolated_encoder.rs
1 use crate::encoder
::EncodeContext
;
2 use crate::schema
::{Lazy, LazySeq}
;
4 use rustc_serialize
::Encodable
;
6 /// The IsolatedEncoder provides facilities to write to crate metadata while
7 /// making sure that anything going through it is also feed into an ICH hasher.
8 pub struct IsolatedEncoder
<'a
, 'b
: 'a
, 'tcx
: 'b
> {
9 pub tcx
: TyCtxt
<'b
, 'tcx
, 'tcx
>,
10 ecx
: &'a
mut EncodeContext
<'b
, 'tcx
>,
13 impl<'a
, 'b
: 'a
, 'tcx
: 'b
> IsolatedEncoder
<'a
, 'b
, 'tcx
> {
15 pub fn new(ecx
: &'a
mut EncodeContext
<'b
, 'tcx
>) -> Self {
23 pub fn lazy
<T
>(&mut self, value
: &T
) -> Lazy
<T
>
29 pub fn lazy_seq
<I
, T
>(&mut self, iter
: I
) -> LazySeq
<T
>
30 where I
: IntoIterator
<Item
= T
>,
33 self.ecx
.lazy_seq(iter
)
36 pub fn lazy_seq_ref
<'x
, I
, T
>(&mut self, iter
: I
) -> LazySeq
<T
>
37 where I
: IntoIterator
<Item
= &'x T
>,
40 self.ecx
.lazy_seq_ref(iter
)
43 pub fn lazy_seq_from_slice
<T
>(&mut self, slice
: &[T
]) -> LazySeq
<T
>
46 self.ecx
.lazy_seq_ref(slice
.iter())