balanced_ternary/
conversions.rs1use crate::{Digit, Ternary};
14use alloc::string::{String, ToString};
15
16impl From<char> for Digit {
17 fn from(value: char) -> Self {
18 Self::from_char(value)
19 }
20}
21
22impl From<i8> for Digit {
23 fn from(value: i8) -> Self {
24 Self::from_i8(value)
25 }
26}
27
28impl From<Digit> for char {
29 fn from(value: Digit) -> Self {
30 value.to_char()
31 }
32}
33
34impl From<Digit> for i8 {
35 fn from(value: Digit) -> Self {
36 value.to_i8()
37 }
38}
39
40impl From<&str> for Ternary {
41 fn from(value: &str) -> Self {
42 Self::parse(value)
43 }
44}
45
46impl From<String> for Ternary {
47 fn from(value: String) -> Self {
48 Self::from(value.as_str())
49 }
50}
51
52impl From<i64> for Ternary {
53 fn from(value: i64) -> Self {
54 Self::from_dec(value)
55 }
56}
57
58impl From<Ternary> for String {
59 fn from(value: Ternary) -> Self {
60 value.to_string()
61 }
62}
63
64impl From<Ternary> for i64 {
65 fn from(value: Ternary) -> Self {
66 value.to_dec()
67 }
68}