Closed Jaebaek-Lee closed 9 months ago
What's an example of where union
is used in Rust outside of defining a new class/data type?
As far as I know, the union
keyword is not used except when defining a new union. The same goes for enum
and struct
, but they are all included in KEYWORDS, so I'm just suggesting it. 😊
The same goes for enum and struct, but they are all included in KEYWORDS
Ha, well that's a good argument.
Is your request related to a specific problem you're having? Rust supports keywords of type
union
. doc.1 doc.2But
union
hasn't been added to the rust.js keyword list in highlight.js yet - all the other keywords are included. https://github.com/highlightjs/highlight.js/blob/8b88a7d4c3e88f157a87b8d50088af329d700eeb/src/languages/rust.js#L73C4-L77C15The solution you'd prefer / feature you'd like to see added... Add the
union
string to the list of keywords in rust.js.Any alternative solutions you considered... When you use union as a purposeful type in your code, it is designed to be properly highlighted. It's just not included in the KEYWORDS array. So maybe you don't need to modify anything. However, if the KEYWORDS array should contain all the keywords supported by rust, it seems like a good idea to add union as well. https://github.com/highlightjs/highlight.js/blob/8b88a7d4c3e88f157a87b8d50088af329d700eeb/src/languages/rust.js#L287-L296
Additional context...
as is
to be