diff options
| author | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2017-03-17 23:41:09 +0000 |
|---|---|---|
| committer | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2017-06-26 02:06:26 +0000 |
| commit | e42836b2085233323339bacb636ecf9c28e8422e (patch) | |
| tree | c43855deb6274dce6bbafb7efb75bd9ac8b95f97 /src/libsyntax/util | |
| parent | 7d41674b175cdb3452e042ef6f37141bc3788f8b (diff) | |
| download | rust-e42836b2085233323339bacb636ecf9c28e8422e.tar.gz rust-e42836b2085233323339bacb636ecf9c28e8422e.zip | |
Implement `quote!` and other `proc_macro` API.
Diffstat (limited to 'src/libsyntax/util')
| -rw-r--r-- | src/libsyntax/util/rc_slice.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libsyntax/util/rc_slice.rs b/src/libsyntax/util/rc_slice.rs index 2d9fd7aa875..d6939d71129 100644 --- a/src/libsyntax/util/rc_slice.rs +++ b/src/libsyntax/util/rc_slice.rs @@ -9,7 +9,7 @@ // except according to those terms. use std::fmt; -use std::ops::Deref; +use std::ops::{Deref, Range}; use std::rc::Rc; use rustc_data_structures::stable_hasher::{StableHasher, StableHasherResult, @@ -30,6 +30,14 @@ impl<T> RcSlice<T> { data: Rc::new(vec.into_boxed_slice()), } } + + pub fn sub_slice(&self, range: Range<usize>) -> Self { + RcSlice { + data: self.data.clone(), + offset: self.offset + range.start as u32, + len: (range.end - range.start) as u32, + } + } } impl<T> Deref for RcSlice<T> { |
