aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-02-13 18:02:25 +0100
committerPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-03-30 13:52:29 +0200
commit553ffc74645b34a8b0a52bcd77a7499ca4f74d37 (patch)
tree25c4f2f6079f73c1338311e95dd8c1970a040df9
parentf9ff02ad6ff0343743ebbfa492a512000445ed52 (diff)
downloadgcc-553ffc74645b34a8b0a52bcd77a7499ca4f74d37.zip
gcc-553ffc74645b34a8b0a52bcd77a7499ca4f74d37.tar.gz
gcc-553ffc74645b34a8b0a52bcd77a7499ca4f74d37.tar.bz2
libproc_macro: Add token_stream module interface
Add the token_stream rust module interface to libproc_macro in order to provide public implementation details for the TokenStream type such as iterators. ChangeLog: * librust/proc_macro/rust/lib.rs: Add token_stream module. * librust/proc_macro/rust/token_stream.rs: Add iterator. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r--librust/proc_macro/rust/lib.rs1
-rw-r--r--librust/proc_macro/rust/token_stream.rs34
2 files changed, 35 insertions, 0 deletions
diff --git a/librust/proc_macro/rust/lib.rs b/librust/proc_macro/rust/lib.rs
index 65cf8eb..2e91dd3 100644
--- a/librust/proc_macro/rust/lib.rs
+++ b/librust/proc_macro/rust/lib.rs
@@ -11,6 +11,7 @@ mod ident;
mod literal;
mod punct;
mod span;
+pub mod token_stream;
/// Determines whether proc_macro has been made accessible to the currently
/// running program.
diff --git a/librust/proc_macro/rust/token_stream.rs b/librust/proc_macro/rust/token_stream.rs
new file mode 100644
index 0000000..3de89df
--- /dev/null
+++ b/librust/proc_macro/rust/token_stream.rs
@@ -0,0 +1,34 @@
+//! Public implementation details for the `TokenStream` type, such as iterators.
+use TokenStream;
+use TokenTree;
+
+/// An iterator over [`TokenStream`]'s [`TokenTree`]s.
+#[derive(Clone)]
+pub struct IntoIter {
+ // Internal implementation details
+}
+
+impl Iterator for IntoIter {
+ type Item = TokenTree;
+
+ fn next(&mut self) -> Option<TokenTree> {
+ todo!("Implement this function")
+ }
+
+ fn size_hint(&self) -> (usize, Option<usize>) {
+ todo!("Implement this function")
+ }
+
+ fn count(self) -> usize {
+ todo!("Implement this function")
+ }
+}
+
+impl IntoIterator for TokenStream {
+ type Item = TokenTree;
+ type IntoIter = IntoIter;
+
+ fn into_iter(self) -> IntoIter {
+ todo!("Implement this function")
+ }
+}