Remove some unused pub functions (#11576)

## Summary

I left anything in `red-knot`, any `with_` methods, etc.
This commit is contained in:
Charlie Marsh 2024-05-28 09:56:51 -04:00 committed by GitHub
parent 3989cb8b56
commit 16acd4913f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 7 additions and 495 deletions

View file

@ -1,12 +1,13 @@
//! Implementation of Printf-Style string formatting
//! as per the [Python Docs](https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting).
use bitflags::bitflags;
use std::{
fmt,
iter::{Enumerate, Peekable},
str::FromStr,
};
use bitflags::bitflags;
use crate::Case;
#[derive(Debug, PartialEq)]
@ -96,19 +97,6 @@ bitflags! {
}
}
impl CConversionFlags {
#[inline]
pub fn sign_string(&self) -> &'static str {
if self.contains(CConversionFlags::SIGN_CHAR) {
"+"
} else if self.contains(CConversionFlags::BLANK_SIGN) {
" "
} else {
""
}
}
}
#[derive(Debug, PartialEq)]
pub enum CFormatQuantity {
Amount(usize),
@ -337,44 +325,12 @@ pub enum CFormatPart<T> {
Spec(CFormatSpec),
}
impl<T> CFormatPart<T> {
#[inline]
pub fn is_specifier(&self) -> bool {
matches!(self, CFormatPart::Spec(_))
}
#[inline]
pub fn has_key(&self) -> bool {
match self {
CFormatPart::Spec(s) => s.mapping_key.is_some(),
CFormatPart::Literal(_) => false,
}
}
}
#[derive(Debug, PartialEq)]
pub struct CFormatStrOrBytes<S> {
parts: Vec<(usize, CFormatPart<S>)>,
}
impl<S> CFormatStrOrBytes<S> {
pub fn check_specifiers(&self) -> Option<(usize, bool)> {
let mut count = 0;
let mut mapping_required = false;
for (_, part) in &self.parts {
if part.is_specifier() {
let has_key = part.has_key();
if count == 0 {
mapping_required = has_key;
} else if mapping_required != has_key {
return None;
}
count += 1;
}
}
Some((count, mapping_required))
}
#[inline]
pub fn iter(&self) -> impl Iterator<Item = &(usize, CFormatPart<S>)> {
self.parts.iter()
@ -430,11 +386,6 @@ impl CFormatBytes {
}
Ok(Self { parts })
}
pub fn parse_from_bytes(bytes: &[u8]) -> Result<Self, CFormatError> {
let mut iter = bytes.iter().copied().enumerate().peekable();
Self::parse(&mut iter)
}
}
pub type CFormatString = CFormatStrOrBytes<String>;