mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
use variables directly in format strings
thanks clippy we love you
This commit is contained in:
parent
7ae8bfab50
commit
9de6c03dfb
17 changed files with 49 additions and 49 deletions
|
@ -15,5 +15,5 @@ async fn main() {
|
|||
)
|
||||
.await
|
||||
.unwrap();
|
||||
println!("{:?}", auth_result);
|
||||
println!("{auth_result:?}");
|
||||
}
|
||||
|
|
|
@ -336,7 +336,7 @@ async fn auth_with_xbox_live(
|
|||
"SiteName": "user.auth.xboxlive.com",
|
||||
// i thought this was supposed to be d={} but it doesn't work for
|
||||
// me when i add it ??????
|
||||
"RpsTicket": format!("{}", access_token)
|
||||
"RpsTicket": format!("{access_token}")
|
||||
},
|
||||
"RelyingParty": "http://auth.xboxlive.com",
|
||||
"TokenType": "JWT"
|
||||
|
@ -359,7 +359,7 @@ async fn auth_with_xbox_live(
|
|||
|
||||
// not_after looks like 2020-12-21T19:52:08.4463796Z
|
||||
let expires_at = DateTime::parse_from_rfc3339(&res.not_after)
|
||||
.map_err(|e| XboxLiveAuthError::InvalidExpiryDate(format!("{}: {}", res.not_after, e)))?
|
||||
.map_err(|e| XboxLiveAuthError::InvalidExpiryDate(format!("{}: {e}", res.not_after)))?
|
||||
.with_timezone(&Utc)
|
||||
.timestamp() as u64;
|
||||
Ok(ExpiringValue {
|
||||
|
@ -416,7 +416,7 @@ async fn auth_with_minecraft(
|
|||
.post("https://api.minecraftservices.com/authentication/login_with_xbox")
|
||||
.header("Accept", "application/json")
|
||||
.json(&json!({
|
||||
"identityToken": format!("XBL3.0 x={};{}", user_hash, xsts_token)
|
||||
"identityToken": format!("XBL3.0 x={user_hash};{xsts_token}")
|
||||
}))
|
||||
.send()
|
||||
.await?
|
||||
|
@ -446,7 +446,7 @@ async fn check_ownership(
|
|||
.get("https://api.minecraftservices.com/entitlements/mcstore")
|
||||
.header(
|
||||
"Authorization",
|
||||
format!("Bearer {}", minecraft_access_token),
|
||||
format!("Bearer {minecraft_access_token}"),
|
||||
)
|
||||
.send()
|
||||
.await?
|
||||
|
@ -474,7 +474,7 @@ async fn get_profile(
|
|||
.get("https://api.minecraftservices.com/minecraft/profile")
|
||||
.header(
|
||||
"Authorization",
|
||||
format!("Bearer {}", minecraft_access_token),
|
||||
format!("Bearer {minecraft_access_token}"),
|
||||
)
|
||||
.send()
|
||||
.await?
|
||||
|
|
|
@ -317,7 +317,7 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
|||
// }
|
||||
let property_variants = properties_map
|
||||
.get(property_name)
|
||||
.unwrap_or_else(|| panic!("Property '{}' not found", property_name))
|
||||
.unwrap_or_else(|| panic!("Property '{property_name}' not found"))
|
||||
.clone();
|
||||
block_properties_vec.push(property_variants);
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
|||
previous_names.push(property_name.clone());
|
||||
if let Some(index) = index {
|
||||
// property_name.push_str(&format!("_{}", &index.to_string()));
|
||||
write!(property_name, "_{}", index).unwrap();
|
||||
write!(property_name, "_{index}").unwrap();
|
||||
}
|
||||
properties_with_name.push(PropertyWithNameAndDefault {
|
||||
name: Ident::new(&property_name, proc_macro2::Span::call_site()),
|
||||
|
@ -391,7 +391,7 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
|||
proc_macro2::Span::call_site(),
|
||||
);
|
||||
let block_struct_name = Ident::new(
|
||||
&format!("{}Block", block_name_pascal_case),
|
||||
&format!("{block_name_pascal_case}Block"),
|
||||
proc_macro2::Span::call_site(),
|
||||
);
|
||||
|
||||
|
|
|
@ -45,35 +45,35 @@ impl fmt::Debug for BuiltInExceptions {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
BuiltInExceptions::DoubleTooSmall { found, min } => {
|
||||
write!(f, "Double must not be less than {}, found {}", min, found)
|
||||
write!(f, "Double must not be less than {min}, found {found}")
|
||||
}
|
||||
BuiltInExceptions::DoubleTooBig { found, max } => {
|
||||
write!(f, "Double must not be more than {}, found {}", max, found)
|
||||
write!(f, "Double must not be more than {max}, found {found}")
|
||||
}
|
||||
|
||||
BuiltInExceptions::FloatTooSmall { found, min } => {
|
||||
write!(f, "Float must not be less than {}, found {}", min, found)
|
||||
write!(f, "Float must not be less than {min}, found {found}")
|
||||
}
|
||||
BuiltInExceptions::FloatTooBig { found, max } => {
|
||||
write!(f, "Float must not be more than {}, found {}", max, found)
|
||||
write!(f, "Float must not be more than {max}, found {found}")
|
||||
}
|
||||
|
||||
BuiltInExceptions::IntegerTooSmall { found, min } => {
|
||||
write!(f, "Integer must not be less than {}, found {}", min, found)
|
||||
write!(f, "Integer must not be less than {min}, found {found}")
|
||||
}
|
||||
BuiltInExceptions::IntegerTooBig { found, max } => {
|
||||
write!(f, "Integer must not be more than {}, found {}", max, found)
|
||||
write!(f, "Integer must not be more than {max}, found {found}")
|
||||
}
|
||||
|
||||
BuiltInExceptions::LongTooSmall { found, min } => {
|
||||
write!(f, "Long must not be less than {}, found {}", min, found)
|
||||
write!(f, "Long must not be less than {min}, found {found}")
|
||||
}
|
||||
BuiltInExceptions::LongTooBig { found, max } => {
|
||||
write!(f, "Long must not be more than {}, found {}", max, found)
|
||||
write!(f, "Long must not be more than {max}, found {found}")
|
||||
}
|
||||
|
||||
BuiltInExceptions::LiteralIncorrect { expected } => {
|
||||
write!(f, "Expected literal {}", expected)
|
||||
write!(f, "Expected literal {expected}")
|
||||
}
|
||||
|
||||
BuiltInExceptions::ReaderExpectedStartOfQuote => {
|
||||
|
@ -97,25 +97,25 @@ impl fmt::Debug for BuiltInExceptions {
|
|||
)
|
||||
}
|
||||
BuiltInExceptions::ReaderInvalidInt { value } => {
|
||||
write!(f, "Invalid Integer '{}'", value)
|
||||
write!(f, "Invalid Integer '{value}'")
|
||||
}
|
||||
BuiltInExceptions::ReaderExpectedInt => {
|
||||
write!(f, "Expected Integer")
|
||||
}
|
||||
BuiltInExceptions::ReaderInvalidLong { value } => {
|
||||
write!(f, "Invalid long '{}'", value)
|
||||
write!(f, "Invalid long '{value}'")
|
||||
}
|
||||
BuiltInExceptions::ReaderExpectedLong => {
|
||||
write!(f, "Expected long")
|
||||
}
|
||||
BuiltInExceptions::ReaderInvalidDouble { value } => {
|
||||
write!(f, "Invalid double '{}'", value)
|
||||
write!(f, "Invalid double '{value}'")
|
||||
}
|
||||
BuiltInExceptions::ReaderExpectedDouble => {
|
||||
write!(f, "Expected double")
|
||||
}
|
||||
BuiltInExceptions::ReaderInvalidFloat { value } => {
|
||||
write!(f, "Invalid Float '{}'", value)
|
||||
write!(f, "Invalid Float '{value}'")
|
||||
}
|
||||
BuiltInExceptions::ReaderExpectedFloat => {
|
||||
write!(f, "Expected Float")
|
||||
|
@ -124,7 +124,7 @@ impl fmt::Debug for BuiltInExceptions {
|
|||
write!(f, "Expected bool")
|
||||
}
|
||||
BuiltInExceptions::ReaderExpectedSymbol { symbol } => {
|
||||
write!(f, "Expected '{}'", symbol)
|
||||
write!(f, "Expected '{symbol}'")
|
||||
}
|
||||
|
||||
BuiltInExceptions::DispatcherUnknownCommand => {
|
||||
|
@ -140,7 +140,7 @@ impl fmt::Debug for BuiltInExceptions {
|
|||
)
|
||||
}
|
||||
BuiltInExceptions::DispatcherParseException { message } => {
|
||||
write!(f, "Could not parse command: {}", message)
|
||||
write!(f, "Could not parse command: {message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,12 +148,12 @@ impl fmt::Debug for BuiltInExceptions {
|
|||
|
||||
impl BuiltInExceptions {
|
||||
pub fn create(self) -> CommandSyntaxException {
|
||||
let message = Message::from(format!("{:?}", self));
|
||||
let message = Message::from(format!("{self:?}"));
|
||||
CommandSyntaxException::create(self, message)
|
||||
}
|
||||
|
||||
pub fn create_with_context(self, reader: &StringReader) -> CommandSyntaxException {
|
||||
let message = Message::from(format!("{:?}", self));
|
||||
let message = Message::from(format!("{self:?}"));
|
||||
CommandSyntaxException::new(self, message, reader.string(), reader.cursor())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ fn execute_redirected_multiple_times() {
|
|||
child2.clone().unwrap().nodes[0].range,
|
||||
child2.clone().unwrap().range
|
||||
);
|
||||
assert_eq!(child2.clone().unwrap().nodes[0].node, concrete_node);
|
||||
assert_eq!(child2.unwrap().nodes[0].node, concrete_node);
|
||||
|
||||
assert_eq!(CommandDispatcher::execute_parsed(parse).unwrap(), 42);
|
||||
}
|
||||
|
@ -406,5 +406,5 @@ fn get_path() {
|
|||
fn find_node_doesnt_exist() {
|
||||
let subject = CommandDispatcher::<()>::new();
|
||||
|
||||
assert_eq!(subject.find_node(&vec!["foo", "bar"]), None)
|
||||
assert_eq!(subject.find_node(&["foo", "bar"]), None)
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ mod tests {
|
|||
let u = Uuid::parse_str("6536bfed-8695-48fd-83a1-ecd24cf2a0fd").unwrap();
|
||||
let mut buf = Vec::new();
|
||||
u.write_into(&mut buf).unwrap();
|
||||
println!("{:?}", buf);
|
||||
println!("{buf:?}");
|
||||
assert_eq!(buf.len(), 16);
|
||||
let u2 = Uuid::read_from(&mut Cursor::new(&buf)).unwrap();
|
||||
assert_eq!(u, u2);
|
||||
|
|
|
@ -186,7 +186,7 @@ impl<'de> Deserialize<'de> for Component {
|
|||
nbt
|
||||
} else {
|
||||
return Err(de::Error::custom(
|
||||
format!("Don't know how to turn {} into a Component", json).as_str(),
|
||||
format!("Don't know how to turn {json} into a Component").as_str(),
|
||||
));
|
||||
};
|
||||
let _separator = Component::parse_separator(&json).map_err(de::Error::custom)?;
|
||||
|
@ -223,7 +223,7 @@ impl<'de> Deserialize<'de> for Component {
|
|||
// ok so it's not an object, if it's an array deserialize every item
|
||||
else if !json.is_array() {
|
||||
return Err(de::Error::custom(
|
||||
format!("Don't know how to turn {} into a Component", json).as_str(),
|
||||
format!("Don't know how to turn {json} into a Component").as_str(),
|
||||
));
|
||||
}
|
||||
let json_array = json.as_array().unwrap();
|
||||
|
|
|
@ -134,8 +134,8 @@ impl Display for TranslatableComponent {
|
|||
impl Display for StringOrComponent {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
match self {
|
||||
StringOrComponent::String(s) => write!(f, "{}", s),
|
||||
StringOrComponent::Component(c) => write!(f, "{}", c),
|
||||
StringOrComponent::String(s) => write!(f, "{s}"),
|
||||
StringOrComponent::Component(c) => write!(f, "{c}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ impl Client {
|
|||
}
|
||||
},
|
||||
Err(e) => {
|
||||
panic!("Error: {:?}", e);
|
||||
panic!("Error: {e:?}");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -300,7 +300,7 @@ impl Client {
|
|||
if IGNORE_ERRORS {
|
||||
continue;
|
||||
} else {
|
||||
panic!("Error handling packet: {}", e);
|
||||
panic!("Error handling packet: {e}");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -308,7 +308,7 @@ impl Client {
|
|||
if IGNORE_ERRORS {
|
||||
warn!("{}", e);
|
||||
match e {
|
||||
ReadPacketError::FrameSplitter { .. } => panic!("Error: {:?}", e),
|
||||
ReadPacketError::FrameSplitter { .. } => panic!("Error: {e:?}"),
|
||||
_ => continue,
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -20,7 +20,7 @@ pub enum Err {
|
|||
impl Debug for Err {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
|
||||
match self {
|
||||
Err::InvalidDifficulty(s) => write!(f, "Invalid difficulty: {}", s),
|
||||
Err::InvalidDifficulty(s) => write!(f, "Invalid difficulty: {s}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ impl Difficulty {
|
|||
2 => Difficulty::NORMAL,
|
||||
3 => Difficulty::HARD,
|
||||
// this shouldn't be possible because of the modulo, so panicking is fine
|
||||
_ => panic!("Unknown difficulty id: {}", id),
|
||||
_ => panic!("Unknown difficulty id: {id}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ impl Axis {
|
|||
0 => Axis::X,
|
||||
1 => Axis::Y,
|
||||
2 => Axis::Z,
|
||||
_ => panic!("Invalid ordinal {}", ordinal),
|
||||
_ => panic!("Invalid ordinal {ordinal}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ impl GameType {
|
|||
"creative" => GameType::CREATIVE,
|
||||
"adventure" => GameType::ADVENTURE,
|
||||
"spectator" => GameType::SPECTATOR,
|
||||
_ => panic!("Unknown game type name: {}", name),
|
||||
_ => panic!("Unknown game type name: {name}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ pub enum Error {
|
|||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Error::InvalidTagType(id) => write!(f, "Invalid tag type: {}", id),
|
||||
Error::InvalidTagType(id) => write!(f, "Invalid tag type: {id}"),
|
||||
Error::InvalidTag => write!(f, "Invalid tag"),
|
||||
Error::WriteError(e) => write!(f, "Write error: {}", e),
|
||||
Error::Utf8Error(e) => write!(f, "Utf8 error: {}", e),
|
||||
Error::WriteError(e) => write!(f, "Write error: {e}"),
|
||||
Error::Utf8Error(e) => write!(f, "Utf8 error: {e}"),
|
||||
Error::UnexpectedEof => write!(f, "Unexpected EOF"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ pub fn box_shape(
|
|||
max_y: f64,
|
||||
max_z: f64,
|
||||
) -> VoxelShape {
|
||||
assert!(min_x >= 0., "min_x must be >= 0 but was {}", min_x);
|
||||
assert!(min_x >= 0., "min_x must be >= 0 but was {min_x}");
|
||||
assert!(min_y >= 0.);
|
||||
assert!(min_z >= 0.);
|
||||
assert!(max_x >= 0.);
|
||||
|
|
|
@ -35,7 +35,7 @@ fn packet_encoder<P: ProtocolPacket + std::fmt::Debug>(
|
|||
return Err(PacketEncodeError::TooBig {
|
||||
actual: buf.len(),
|
||||
maximum: MAXIMUM_UNCOMPRESSED_LENGTH as usize,
|
||||
packet_string: format!("{:?}", packet),
|
||||
packet_string: format!("{packet:?}"),
|
||||
});
|
||||
}
|
||||
Ok(buf)
|
||||
|
|
|
@ -76,8 +76,8 @@ pub fn registry(input: TokenStream) -> TokenStream {
|
|||
|
||||
let max_id = input.items.len() as u32;
|
||||
|
||||
let doc_0 = format!("Transmutes a u32 to a {}.", name);
|
||||
let doc_1 = format!("The `id` should be at most {}.", max_id);
|
||||
let doc_0 = format!("Transmutes a u32 to a {name}.");
|
||||
let doc_1 = format!("The `id` should be at most {max_id}.");
|
||||
|
||||
generated.extend(quote! {
|
||||
impl #name {
|
||||
|
@ -97,7 +97,7 @@ pub fn registry(input: TokenStream) -> TokenStream {
|
|||
}
|
||||
});
|
||||
|
||||
let doc_0 = format!("Safely transmutes a u32 to a {}.", name);
|
||||
let doc_0 = format!("Safely transmutes a u32 to a {name}.");
|
||||
|
||||
generated.extend(quote! {
|
||||
impl TryFrom<u32> for #name {
|
||||
|
|
|
@ -158,7 +158,7 @@ impl Chunk {
|
|||
}
|
||||
|
||||
pub fn section_index(&self, y: i32, min_y: i32) -> u32 {
|
||||
assert!(y >= min_y, "y ({}) must be at least {}", y, min_y);
|
||||
assert!(y >= min_y, "y ({y}) must be at least {min_y}");
|
||||
let min_section_index = min_y.div_floor(16);
|
||||
(y.div_floor(16) - min_section_index) as u32
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue