-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sources case-insensitive; closes #10
- Loading branch information
Showing
4 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
[tools] | ||
rojo = { source = "rojo-rbx/rojo", version = "0.5.0" } | ||
rojo = { source = "rojo-rbx/rojo", version = "0.5.0" } | ||
rojo2 = { source = "rOjO-rBx/rOjo", version = "0.5.0" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::{ | ||
fmt, | ||
hash::{Hash, Hasher}, | ||
}; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Case-insensitive string. | ||
/// | ||
/// A string that acts case-insensitive when compared or hashed, but preserves | ||
/// its case. | ||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
#[serde(transparent)] | ||
pub struct CiString(pub String); | ||
|
||
impl fmt::Display for CiString { | ||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
formatter.write_str(&self.0) | ||
} | ||
} | ||
|
||
impl Hash for CiString { | ||
fn hash<H: Hasher>(&self, state: &mut H) { | ||
let mut buf = [0; 4]; | ||
for outer in self.0.chars() { | ||
for normalized in outer.to_lowercase() { | ||
normalized.encode_utf8(&mut buf); | ||
state.write(&buf); | ||
} | ||
} | ||
|
||
state.write_u8(0xff); | ||
} | ||
} | ||
|
||
impl PartialEq for CiString { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.0 | ||
.chars() | ||
.flat_map(char::to_lowercase) | ||
.eq(other.0.chars().flat_map(char::to_lowercase)) | ||
} | ||
} | ||
|
||
impl Eq for CiString {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
mod aliaser; | ||
mod artifact_choosing; | ||
mod auth_store; | ||
mod ci_string; | ||
mod config; | ||
mod fs; | ||
mod github; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters