pub struct CommentTokens {
pub line: Option<String>,
pub block_start: Option<String>,
pub block_end: Option<String>,
}Expand description
Comment syntax for a language.
Describes how to create line and block comments.
§Example
use reovim_driver_syntax::CommentTokens;
// C-style comments
let c_style = CommentTokens::with_block("//", "/*", "*/");
assert!(c_style.has_line_comment());
assert!(c_style.has_block_comment());
// Python-style (line only)
let python = CommentTokens::line_only("#");
assert!(python.has_line_comment());
assert!(!python.has_block_comment());
// HTML-style (block only)
let html = CommentTokens::block_only("<!--", "-->");
assert!(!html.has_line_comment());
assert!(html.has_block_comment());Fields§
§line: Option<String>Line comment prefix (e.g., “//”, “#”, “–”).
block_start: Option<String>Block comment start (e.g., “/*”, “<!–”).
block_end: Option<String>Block comment end (e.g., “*/”, “–>”).
Implementations§
Source§impl CommentTokens
impl CommentTokens
Sourcepub fn line_only(prefix: impl Into<String>) -> Self
pub fn line_only(prefix: impl Into<String>) -> Self
Create comment tokens with only a line comment.
Sourcepub fn with_block(
line: impl Into<String>,
block_start: impl Into<String>,
block_end: impl Into<String>,
) -> Self
pub fn with_block( line: impl Into<String>, block_start: impl Into<String>, block_end: impl Into<String>, ) -> Self
Create comment tokens with both line and block comments.
Sourcepub fn block_only(start: impl Into<String>, end: impl Into<String>) -> Self
pub fn block_only(start: impl Into<String>, end: impl Into<String>) -> Self
Create comment tokens with only block comments (no line comments).
Sourcepub const fn has_line_comment(&self) -> bool
pub const fn has_line_comment(&self) -> bool
Check if line comments are supported.
Sourcepub const fn has_block_comment(&self) -> bool
pub const fn has_block_comment(&self) -> bool
Check if block comments are supported.
Trait Implementations§
Source§impl Clone for CommentTokens
impl Clone for CommentTokens
Source§fn clone(&self) -> CommentTokens
fn clone(&self) -> CommentTokens
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CommentTokens
impl Debug for CommentTokens
Source§impl Default for CommentTokens
impl Default for CommentTokens
Source§fn default() -> CommentTokens
fn default() -> CommentTokens
Returns the “default value” for a type. Read more
Source§impl PartialEq for CommentTokens
impl PartialEq for CommentTokens
impl Eq for CommentTokens
impl StructuralPartialEq for CommentTokens
Auto Trait Implementations§
impl Freeze for CommentTokens
impl RefUnwindSafe for CommentTokens
impl Send for CommentTokens
impl Sync for CommentTokens
impl Unpin for CommentTokens
impl UnsafeUnpin for CommentTokens
impl UnwindSafe for CommentTokens
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more