Skip to content

Commit 3c110d7

Browse files
committed
docs: Add when text is normalized
1 parent 4266504 commit 3c110d7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/snippet.rs

+21
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ pub enum Level {
166166
}
167167

168168
impl Level {
169+
/// Text passed to this function is considered "untrusted input", as such
170+
/// all text is passed through a normalization function. Pre-styled text is
171+
/// not allowed to be passed to this function.
169172
pub fn message(self, title: &str) -> Message<'_> {
170173
Message {
171174
id: None,
@@ -222,6 +225,9 @@ pub struct Snippet<'a, T> {
222225
}
223226

224227
impl<'a, T: Clone> Snippet<'a, T> {
228+
/// Text passed to this function is considered "untrusted input", as such
229+
/// all text is passed through a normalization function. Pre-styled text is
230+
/// not allowed to be passed to this function.
225231
pub fn source(source: &'a str) -> Self {
226232
Self {
227233
origin: None,
@@ -237,6 +243,9 @@ impl<'a, T: Clone> Snippet<'a, T> {
237243
self
238244
}
239245

246+
/// Text passed to this function is considered "untrusted input", as such
247+
/// all text is passed through a normalization function. Pre-styled text is
248+
/// not allowed to be passed to this function.
240249
pub fn origin(mut self, origin: &'a str) -> Self {
241250
self.origin = Some(origin);
242251
self
@@ -281,6 +290,9 @@ pub struct Annotation<'a> {
281290
}
282291

283292
impl<'a> Annotation<'a> {
293+
/// Text passed to this function is considered "untrusted input", as such
294+
/// all text is passed through a normalization function. Pre-styled text is
295+
/// not allowed to be passed to this function.
284296
pub fn label(mut self, label: &'a str) -> Self {
285297
self.label = Some(label);
286298
self
@@ -322,6 +334,9 @@ pub struct Patch<'a> {
322334
}
323335

324336
impl<'a> Patch<'a> {
337+
/// Text passed to this function is considered "untrusted input", as such
338+
/// all text is passed through a normalization function. Pre-styled text is
339+
/// not allowed to be passed to this function.
325340
pub fn new(range: Range<usize>, replacement: &'a str) -> Self {
326341
Self { range, replacement }
327342
}
@@ -384,6 +399,9 @@ pub struct Origin<'a> {
384399
}
385400

386401
impl<'a> Origin<'a> {
402+
/// Text passed to this function is considered "untrusted input", as such
403+
/// all text is passed through a normalization function. Pre-styled text is
404+
/// not allowed to be passed to this function.
387405
pub fn new(origin: &'a str) -> Self {
388406
Self {
389407
origin,
@@ -409,6 +427,9 @@ impl<'a> Origin<'a> {
409427
self
410428
}
411429

430+
/// Text passed to this function is considered "untrusted input", as such
431+
/// all text is passed through a normalization function. Pre-styled text is
432+
/// not allowed to be passed to this function.
412433
pub fn label(mut self, label: &'a str) -> Self {
413434
self.label = Some(label);
414435
self

0 commit comments

Comments
 (0)