pub use std::iter::repeat_with;
pub use std::marker::PhantomData;
pub use std::mem;
-pub use std::num::{TryFromIntError, Wrapping};
+pub use std::num::{NonZeroUsize, TryFromIntError, Wrapping};
pub use std::ops::{Deref, DerefMut};
pub use std::os::unix;
pub use std::os::unix::ffi::OsStrExt;
type PL = PresentationLayout;
+pub fn player_dasharray(player_num: NonZeroUsize) -> String {
+ let n: usize = player_num.into();
+ let mut dasharray = String::with_capacity(n*3 + 4);
+ for dash in iter::once("3").chain(
+ iter::repeat("1").take(n-1))
+ {
+ write!(&mut dasharray, "{} 1 ", &dash).unwrap();
+ }
+ let spc = dasharray.pop();
+ assert_eq!(spc,Some(' '));
+ dasharray
+}
+
impl PresentationLayout {
pub fn template(self) -> &'static str {
match self {
let n = kd.get_idx_version().0;
let n = if n != 0 { n.try_into().unwrap() }
else { ig.gs.players.capacity() };
- assert!(n != 0);
- let mut dasharray = String::with_capacity(n*3 + 4);
- for dash in iter::once("3").chain(
- iter::repeat("1").take(n-1))
- {
- write!(&mut dasharray, "{} 1 ", &dash).unwrap();
- }
- let spc = dasharray.pop();
- assert_eq!(spc,Some(' '));
+ let dasharray = player_dasharray(n.try_into().unwrap());
DataLoadPlayer {
dasharray,
}