浏览代码

LibWeb: Allow creating a TokenStream from a single token

This is quite niche, but lets us convert parsing methods to accepting
TokenStream, while still being able to call them when we just have a
lone token. Specifically we'll use this in the next commit, but it's
likely to also be useful as a stop-gap measure when converting more
parsing methods.
Sam Atkins 1 年之前
父节点
当前提交
a76f29e56b
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      Userland/Libraries/LibWeb/CSS/Parser/TokenStream.h

+ 5 - 0
Userland/Libraries/LibWeb/CSS/Parser/TokenStream.h

@@ -66,6 +66,11 @@ public:
     {
     }
 
+    static TokenStream<T> of_single_token(T const& token)
+    {
+        return TokenStream(Span<T const> { &token, 1 });
+    }
+
     TokenStream(TokenStream<T> const&) = delete;
     TokenStream(TokenStream<T>&&) = default;