[][src]Struct tweep::Warning

pub struct Warning {
    pub warning_type: WarningType,
    pub position: Position,
    pub referent: Option<Position>,
}

A warning with a WarningType, Position, and optionally a reference to another Position

Examples

use tweep::{Position, Warning, WarningType};
let warning = Warning::new(WarningType::DuplicateStoryTitle)
    .with_referent(Position::RowColumn(5, 0));

Fields

warning_type: WarningType

The warning type

position: Position

The location of the warning

referent: Option<Position>

The location referenced by this warning

Methods

impl Warning[src]

pub fn new(warning_type: WarningType) -> Self[src]

Creates a new Warning with a default Position and no referent

Examples

use tweep::{Warning, WarningType};
let warning = Warning::new(WarningType::MissingStartPassage);

pub fn has_referent(&self) -> bool[src]

Returns true if this Warning has a referent

Examples

use tweep::{Position, Warning, WarningType};
let mut warning = Warning::new(WarningType::UnclosedLink);
assert!(!warning.has_referent());
warning.set_referent(Position::RowColumn(23, 5));
assert!(warning.has_referent());

pub fn get_referent(&self) -> Option<&Position>[src]

Gets the referent if one exists

Examples

use tweep::{Position, Warning, WarningType};
let warning = Warning::new(WarningType::DuplicateStoryTitle)
    .with_referent(Position::RowColumn(5, 0));
assert_eq!(warning.get_referent(), Some(&Position::RowColumn(5, 0)));

pub fn set_referent(&mut self, referent: Position)[src]

Sets the referent to the given Position

Examples

use tweep::{Position, Warning, WarningType};
let mut warning = Warning::new(WarningType::UnclosedLink);
assert!(!warning.has_referent());
warning.set_referent(Position::RowColumn(23, 5));
assert!(warning.has_referent());
assert_eq!(warning.get_referent(), Some(&Position::RowColumn(23, 5)));

pub fn with_referent(self, referent: Position) -> Self[src]

Moves the object, sets the referent to the given Position, and returns the modified object

Examples

use tweep::{Position, Warning, WarningType};
let warning = Warning::new(WarningType::DuplicateStoryTitle)
    .with_referent(Position::RowColumn(5, 0));

Trait Implementations

impl Clone for Warning[src]

impl Debug for Warning[src]

impl Display for Warning[src]

impl Eq for Warning[src]

impl PartialEq<Warning> for Warning[src]

impl Positional for Warning[src]

impl StructuralEq for Warning[src]

impl StructuralPartialEq for Warning[src]

Auto Trait Implementations

impl RefUnwindSafe for Warning

impl Send for Warning

impl Sync for Warning

impl Unpin for Warning

impl UnwindSafe for Warning

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.