pub fn ter(from: &str) -> TernaryExpand description
Converts a string representation of a balanced ternary number into a Ternary object.
This function is a convenient shorthand for creating Ternary numbers
from string representations. The input string must consist of balanced
ternary characters: +, 0, and -.
§Arguments
from- A string slice representing the balanced ternary number.- Panics if an input character is invalid.
§Returns
A Ternary object created from the provided string representation.
§Example
use balanced_ternary::{ter, Ternary};
let ternary = ter("+-0+");
assert_eq!(ternary.to_string(), "+-0+");
let ternary = "+-0+".parse::<Ternary>().unwrap();
assert_eq!(ternary.to_string(), "+-0+");