Struct bellframe::place_not::PlaceNot[][src]

pub struct PlaceNot { /* fields omitted */ }
Expand description

A single piece of place notation on any Stage.

Implementations

Parse a string, interpreting it as a single PlaceNot of a given Stage. Like Row::parse_with_stage, this ignores chars that don’t correspond to valid Bell names, including &, ., , and + which have reserved meanings in blocks of place notation. This will expand implicit places (even between two written places) but will fail if there is any kind of ambiguity, returning a ParseError describing the problem. This also runs in O(n) time except for sorting the places which takes O(n log n) time.

Example

use proj_core::{Stage, PlaceNot, place_not::ParseError};

// Parsing a valid place notation is OK
assert_eq!(PlaceNot::parse("14", Stage::MAJOR)?.to_string(), "14");
// Ordering and rogue chars don't matter
assert_eq!(PlaceNot::parse("  4|7~18", Stage::ROYAL)?.to_string(), "1478");
// Implicit places will be expanded
assert_eq!(PlaceNot::parse("467", Stage::MAXIMUS)?.to_string(), "14567T");

// Parsing invalid or ambiguous PN is not OK, and warns you of the problem
assert_eq!(
    PlaceNot::parse("14T", Stage::MAJOR).unwrap_err().to_string(),
    "Place 'T' is out stage Major"
);
assert_eq!(
    PlaceNot::parse("15", Stage::MAJOR).unwrap_err().to_string(),
    "Ambiguous gap of 3 bells between places '1' and '5'."
);

Creates a new PlaceNot from a sorted slice of places, performing bounds checks and returning errors if necessary.

Safety

This function is safe if parsed_places is sorted into increasing order

Returns a new PlaceNot representing the ‘cross’ notation on a given stage. This will fail if stage doesn’t have an even number of bells.

Example

use proj_core::{PlaceNot, Stage};

// These are crosses
assert_eq!(
    PlaceNot::cross(Stage::MAJOR).unwrap(),
    PlaceNot::parse("x", Stage::MAJOR)?
);

Checks if this PlaceNot corresponds to the ‘cross’ notation.

Example

use proj_core::{PlaceNot, Stage};

// These are crosses
assert!(PlaceNot::cross(Stage::MAJOR).unwrap().is_cross());
assert!(PlaceNot::parse("x", Stage::MAJOR)?.is_cross());
// These are not
assert!(!PlaceNot::parse("14", Stage::MAJOR)?.is_cross());
assert!(!PlaceNot::parse("3", Stage::TRIPLES)?.is_cross());

Checks whether a given place is made in this PlaceNot.

Returns the Stage of this PlaceNot

Uses this PlaceNot to perform an in-place permutation of a given Row. If you want to to preserve the old Row, then use permute_new.

Uses this PlaceNot to perform an in-place permutation of a given Row, without checking that the Stages match. If you want to to preserve the old Row, then use permute_new_unchecked.

Safety

This function is safe to use only when self.stage() == row.stage().

Uses this PlaceNot to permute a given Row, preserving the old copy and returning a new Row. This checks that the Stages are equal, and is therefore safe.

Uses this PlaceNot to permute a given Row, preserving the old copy and returning a new Row.

Safety

This function is safe to use only when self.stage() == row.stage().

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

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Performs the conversion.

Performs the conversion.

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)

recently added

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

Converts the given value to a String. 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.