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'." );
pub unsafe fn from_sorted_slice(
parsed_places: &[usize],
stage: Stage
) -> Result<Self, ParseError>
[src]
pub unsafe fn from_sorted_slice(
parsed_places: &[usize],
stage: Stage
) -> Result<Self, ParseError>
[src]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
.
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 Stage
s 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()
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for PlaceNot
impl UnwindSafe for PlaceNot
Blanket Implementations
Mutably borrows from an owned value. Read more