Skip to content

Commit 4ff3c1e

Browse files
authored
make Label::new public again, add comment
1 parent 1952056 commit 4ff3c1e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/diagnostic.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ pub trait Diagnostic: Sized {
2121
fn labels(&self, subject: &Self::Subject) -> Option<Box<dyn Iterator<Item = Label>>>;
2222
}
2323

24-
/// A label for a span within a json pointer or malformed string.
25-
///
24+
/// A label for a span within a JSON Pointer or malformed string.
2625
#[derive(Debug, PartialEq, Eq, Clone)]
2726
pub struct Label {
2827
text: String,
@@ -32,7 +31,10 @@ pub struct Label {
3231

3332
impl Label {
3433
/// Creates a new instance of a [`Label`] from its parts
35-
pub(crate) fn new(text: String, offset: usize, len: usize) -> Self {
34+
// NOTE: this is deliberately public, so that users can use
35+
// the `Assign` and `Resolve` traits with custom types and errors,
36+
// and then implement `Diagnostic` for those errors.
37+
pub fn new(text: String, offset: usize, len: usize) -> Self {
3638
Self { text, offset, len }
3739
}
3840
}

0 commit comments

Comments
 (0)