Struct erg_common::error::SubMessage
source · pub struct SubMessage {
pub loc: Location,
pub msg: Vec<String>,
pub hint: Option<String>,
}
Fields§
§loc: Location
§msg: Vec<String>
§hint: Option<String>
Implementations§
source§impl SubMessage
impl SubMessage
sourcepub fn ambiguous_new(
loc: Location,
msg: Vec<String>,
hint: Option<String>
) -> Self
pub fn ambiguous_new( loc: Location, msg: Vec<String>, hint: Option<String> ) -> Self
Used when the msg or hint is empty.
msg
is type of Vec<String>
instead of Option<String>
because it can be used when there are multiple msg
s as well as multiple lines.
Example
let loc = Location::Line(1);
let msg = SubMessage::ambiguous_new(loc, vec![], None); // this code same as only_loc()
let hint = Some("hint message here".to_string());
let msg = SubMessage::ambiguous_new(loc, vec![], hint);
/* example
-------
`- hint message here
*/
let hint = Some("hint here".to_string());
let first = StyledString::new("1th message", Some(Color::Red), None);
let second = StyledString::new("2th message", Some(Color::White), None);
let nth = StyledString::new("nth message", Some(Color::Green), None);
let msg = SubMessage::ambiguous_new(
loc,
vec![
first.to_string(),
second.to_string(),
// ...,
nth.to_string(),
],
hint);
/* example
-------
:- 1th message
:- 2th message
:
:- nth message
`- hint here
*/
sourcepub fn only_loc(loc: Location) -> Self
pub fn only_loc(loc: Location) -> Self
Used when only Location is fixed. In this case, error position is just modified
Example
let loc = Location::Line(1);
let sub_msg = SubMessage::only_loc(loc);
pub fn set_hint<S: Into<String>>(&mut self, hint: S)
pub fn get_hint(&self) -> Option<&str>
pub fn get_msg(&self) -> &[String]
Trait Implementations§
source§impl Clone for SubMessage
impl Clone for SubMessage
source§fn clone(&self) -> SubMessage
fn clone(&self) -> SubMessage
Returns a copy 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 SubMessage
impl Debug for SubMessage
source§impl Hash for SubMessage
impl Hash for SubMessage
source§impl PartialEq<SubMessage> for SubMessage
impl PartialEq<SubMessage> for SubMessage
source§fn eq(&self, other: &SubMessage) -> bool
fn eq(&self, other: &SubMessage) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.