Struct letter_sequence::sequence::builder::SequenceBuilder[][src]

pub struct SequenceBuilder { /* fields omitted */ }
Expand description
use letter_sequence::sequence::builder;
use std::convert::TryFrom;

let mut seq = builder::SequenceBuilder::try_from("Z")
  .unwrap()
	.upper()
	.build()
	.unwrap();
assert_eq!( seq.to_string(), "Z" );
seq.next();
assert_eq!( seq.to_string(), "AA" );

This time with .max_render_capacity() set, and lowercase

use letter_sequence::sequence::builder;
use std::convert::TryFrom;

let mut seq = builder::SequenceBuilder::try_from('y')
  .unwrap()
	.lower()
	.max_render_capacity(1)
	.build()
	.unwrap();
assert_eq!( seq.next().unwrap().to_string(), "z"  );
assert_eq!( seq.to_string(),                 "z"  );
// Without .max_render_capacity(1) this would reutrn "aa"
assert_eq!( seq.next(),                      None );

Also boring number sequence

use letter_sequence::sequence::builder;
use std::convert::TryFrom;

let mut seq = builder::SequenceBuilder::from(102)
	.numeric()
	.build()
	.unwrap();
assert_eq!( seq.next().unwrap().to_string(), "103"  );
assert_eq!( seq.to_string(),                 "103"  );

Implementations

Creates a new Sequence starting at start (0-base)

use letter_sequence::sequence::builder;

let seq = builder::SequenceBuilder::new(2).upper().build().unwrap();
assert_eq!( seq.to_string(), "C" );

let seq = builder::SequenceBuilder::new(5).build().unwrap();
assert_eq!( seq.to_string(), "5" );

Limits the chacters in rendered output, incrementing past limit generates error. default: unlimited

Limits the minimum width of the rendered output, this only works on Numeric which effectively zero-pads the output.

Render the sequence in lowercase

Render the sequence in uppercase, default

Render the sequence in digits

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Performs the conversion.

use letter_sequence::sequence::builder::SequenceBuilder;
use std::convert::TryFrom;
assert_eq!(
	SequenceBuilder::try_from("00001")
		.unwrap()
		.build()
		.unwrap()
		.to_string(),
	"1"
);
assert_eq!(
	SequenceBuilder::try_from("00001")
		.unwrap()
		.upper()
		.build()
		.unwrap()
		.to_string(),
	"B"
);

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.

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 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.