utls 0.13.10

A simple utilities library for stuff I actually use sometimes, with a large focus on convenience and lack of dependencies.
Documentation
use std::io::{stdout, Write};

#[allow(dead_code)]
pub fn cleanup_terminal() {
    // Show cursor and move to next line
    let mut stdout = stdout().lock();
    let _ = writeln!(stdout, "\x1B[?25h");
    let _ = stdout.flush();
}
// Finally, another function in helpers!
#[allow(dead_code)]
pub fn detect_radix(s: &str) -> Option<u32> {
    if s.is_empty() {
        return None;
    }

    let s = s.trim().to_uppercase();
    let mut max_digit = 0;

    // Find the highest "digit" in the string
    for c in s.chars() {
        let value = match c {
            '0'..='9' => c as u32 - '0' as u32,
            'A'..='Z' => c as u32 - 'A' as u32 + 10,
            _ => return None, // Invalid character
        };
        max_digit = max_digit.max(value);
    }

    // The radix must be at least max_digit + 1
    let radix = max_digit + 1;
    
    // Clamp the radix between 2 and 36
    if radix < 2 {
        Some(2) // Default to binary for strings with only 0s and 1s
    } else if radix > 36 {
        None // Invalid radix
    } else {
        Some(radix)
    }
}