pub struct CommentSettings { /* private fields */ }
Expand description

Settings for StripComments

The default is for all comment types to be enabled.

Implementations

Enable all comment Styles

Only allow line comments starting with #

Only allow “c-style” comments.

Specifically, line comments beginning with // and block comment like /* ... */.

Create a new StripComments for input, using these settings.

Transform input into a Read that strips out comments. The types of comments to support are determined by the configuration of self.

Examples
use json_comments::CommentSettings;
use std::io::Read;

let input = r#"{
// c line comment
"a": "b"
/** multi line
comment
*/ }"#;

let mut stripped = String::new();
CommentSettings::c_style().strip_comments(input.as_bytes()).read_to_string(&mut stripped).unwrap();

assert_eq!(stripped, "{
                 \n\"a\": \"b\"
                          }");
use json_comments::CommentSettings;
use std::io::Read;

let input = r#"{
# shell line comment
"a": "b"
}"#;

let mut stripped = String::new();
CommentSettings::hash_only().strip_comments(input.as_bytes()).read_to_string(&mut stripped).unwrap();

assert_eq!(stripped, "{
                    \n\"a\": \"b\"\n}");

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.