From 6c217f7b663e3fad6e9cfc8213be0c4c0981734e Mon Sep 17 00:00:00 2001 From: LukeMathWalker <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 22 May 2024 12:06:40 +0200 Subject: [PATCH] Use "bytes" instead of "characters" consistently when talking about length of a `String`. --- book/src/05_ticket_v2/06_fallibility.md | 4 ++-- exercises/03_ticket_v1/02_validation/src/lib.rs | 4 ++-- exercises/03_ticket_v1/03_modules/src/lib.rs | 4 ++-- exercises/03_ticket_v1/04_visibility/src/lib.rs | 4 ++-- exercises/03_ticket_v1/05_encapsulation/src/lib.rs | 4 ++-- exercises/03_ticket_v1/06_ownership/src/lib.rs | 4 ++-- exercises/03_ticket_v1/07_setters/src/lib.rs | 8 ++++---- exercises/03_ticket_v1/12_outro/src/lib.rs | 2 +- exercises/04_traits/05_str_slice/src/lib.rs | 4 ++-- exercises/05_ticket_v2/01_enum/src/lib.rs | 4 ++-- exercises/05_ticket_v2/03_variants_with_data/src/lib.rs | 4 ++-- exercises/05_ticket_v2/05_nullability/src/lib.rs | 4 ++-- exercises/05_ticket_v2/06_fallibility/src/lib.rs | 8 ++++---- exercises/05_ticket_v2/07_unwrap/src/lib.rs | 6 +++--- exercises/05_ticket_v2/08_error_enums/src/lib.rs | 6 +++--- exercises/05_ticket_v2/09_error_trait/src/lib.rs | 6 +++--- exercises/05_ticket_v2/12_thiserror/src/lib.rs | 4 ++-- exercises/05_ticket_v2/14_source/src/lib.rs | 4 ++-- exercises/05_ticket_v2/15_outro/src/description.rs | 4 ++-- exercises/05_ticket_v2/15_outro/src/title.rs | 5 +---- helpers/ticket_fields/src/description.rs | 4 ++-- helpers/ticket_fields/src/title.rs | 7 ++----- 22 files changed, 49 insertions(+), 55 deletions(-) diff --git a/book/src/05_ticket_v2/06_fallibility.md b/book/src/05_ticket_v2/06_fallibility.md index f89d1af..7e2877f 100644 --- a/book/src/05_ticket_v2/06_fallibility.md +++ b/book/src/05_ticket_v2/06_fallibility.md @@ -9,13 +9,13 @@ impl Ticket { panic!("Title cannot be empty"); } if title.len() > 50 { - panic!("Title cannot be longer than 50 characters"); + panic!("Title cannot be longer than 50 bytes"); } if description.is_empty() { panic!("Description cannot be empty"); } if description.len() > 500 { - panic!("Description cannot be longer than 500 characters"); + panic!("Description cannot be longer than 500 bytes"); } Ticket { diff --git a/exercises/03_ticket_v1/02_validation/src/lib.rs b/exercises/03_ticket_v1/02_validation/src/lib.rs index 6fbdc67..d7416eb 100644 --- a/exercises/03_ticket_v1/02_validation/src/lib.rs +++ b/exercises/03_ticket_v1/02_validation/src/lib.rs @@ -44,13 +44,13 @@ mod tests { } #[test] - #[should_panic(expected = "Title cannot be longer than 50 characters")] + #[should_panic(expected = "Title cannot be longer than 50 bytes")] fn title_cannot_be_longer_than_fifty_chars() { Ticket::new(overly_long_title(), valid_description(), "To-Do".into()); } #[test] - #[should_panic(expected = "Description cannot be longer than 500 characters")] + #[should_panic(expected = "Description cannot be longer than 500 bytes")] fn description_cannot_be_longer_than_500_chars() { Ticket::new(valid_title(), overly_long_description(), "To-Do".into()); } diff --git a/exercises/03_ticket_v1/03_modules/src/lib.rs b/exercises/03_ticket_v1/03_modules/src/lib.rs index 845b2af..df07620 100644 --- a/exercises/03_ticket_v1/03_modules/src/lib.rs +++ b/exercises/03_ticket_v1/03_modules/src/lib.rs @@ -19,13 +19,13 @@ impl Ticket { panic!("Title cannot be empty"); } if title.len() > 50 { - panic!("Title cannot be longer than 50 characters"); + panic!("Title cannot be longer than 50 bytes"); } if description.is_empty() { panic!("Description cannot be empty"); } if description.len() > 500 { - panic!("Description cannot be longer than 500 characters"); + panic!("Description cannot be longer than 500 bytes"); } if status != "To-Do" && status != "In Progress" && status != "Done" { panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed"); diff --git a/exercises/03_ticket_v1/04_visibility/src/lib.rs b/exercises/03_ticket_v1/04_visibility/src/lib.rs index ff8c41b..4fdcc1e 100644 --- a/exercises/03_ticket_v1/04_visibility/src/lib.rs +++ b/exercises/03_ticket_v1/04_visibility/src/lib.rs @@ -11,13 +11,13 @@ mod ticket { panic!("Title cannot be empty"); } if title.len() > 50 { - panic!("Title cannot be longer than 50 characters"); + panic!("Title cannot be longer than 50 bytes"); } if description.is_empty() { panic!("Description cannot be empty"); } if description.len() > 500 { - panic!("Description cannot be longer than 500 characters"); + panic!("Description cannot be longer than 500 bytes"); } if status != "To-Do" && status != "In Progress" && status != "Done" { panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed"); diff --git a/exercises/03_ticket_v1/05_encapsulation/src/lib.rs b/exercises/03_ticket_v1/05_encapsulation/src/lib.rs index 08f8654..91e06eb 100644 --- a/exercises/03_ticket_v1/05_encapsulation/src/lib.rs +++ b/exercises/03_ticket_v1/05_encapsulation/src/lib.rs @@ -11,13 +11,13 @@ pub mod ticket { panic!("Title cannot be empty"); } if title.len() > 50 { - panic!("Title cannot be longer than 50 characters"); + panic!("Title cannot be longer than 50 bytes"); } if description.is_empty() { panic!("Description cannot be empty"); } if description.len() > 500 { - panic!("Description cannot be longer than 500 characters"); + panic!("Description cannot be longer than 500 bytes"); } if status != "To-Do" && status != "In Progress" && status != "Done" { panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed"); diff --git a/exercises/03_ticket_v1/06_ownership/src/lib.rs b/exercises/03_ticket_v1/06_ownership/src/lib.rs index 74cbb29..ded2ad8 100644 --- a/exercises/03_ticket_v1/06_ownership/src/lib.rs +++ b/exercises/03_ticket_v1/06_ownership/src/lib.rs @@ -15,13 +15,13 @@ impl Ticket { panic!("Title cannot be empty"); } if title.len() > 50 { - panic!("Title cannot be longer than 50 characters"); + panic!("Title cannot be longer than 50 bytes"); } if description.is_empty() { panic!("Description cannot be empty"); } if description.len() > 500 { - panic!("Description cannot be longer than 500 characters"); + panic!("Description cannot be longer than 500 bytes"); } if status != "To-Do" && status != "In Progress" && status != "Done" { panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed"); diff --git a/exercises/03_ticket_v1/07_setters/src/lib.rs b/exercises/03_ticket_v1/07_setters/src/lib.rs index 5e2ff52..9aa4301 100644 --- a/exercises/03_ticket_v1/07_setters/src/lib.rs +++ b/exercises/03_ticket_v1/07_setters/src/lib.rs @@ -14,13 +14,13 @@ impl Ticket { panic!("Title cannot be empty"); } if title.len() > 50 { - panic!("Title cannot be longer than 50 characters"); + panic!("Title cannot be longer than 50 bytes"); } if description.is_empty() { panic!("Description cannot be empty"); } if description.len() > 500 { - panic!("Description cannot be longer than 500 characters"); + panic!("Description cannot be longer than 500 bytes"); } if status != "To-Do" && status != "In Progress" && status != "Done" { panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed"); @@ -76,14 +76,14 @@ mod tests { } #[test] - #[should_panic(expected = "Title cannot be longer than 50 characters")] + #[should_panic(expected = "Title cannot be longer than 50 bytes")] fn title_cannot_be_longer_than_fifty_chars() { Ticket::new(valid_title(), valid_description(), "To-Do".into()) .set_title(overly_long_title()) } #[test] - #[should_panic(expected = "Description cannot be longer than 500 characters")] + #[should_panic(expected = "Description cannot be longer than 500 bytes")] fn description_cannot_be_longer_than_500_chars() { Ticket::new(valid_title(), valid_description(), "To-Do".into()) .set_description(overly_long_description()) diff --git a/exercises/03_ticket_v1/12_outro/src/lib.rs b/exercises/03_ticket_v1/12_outro/src/lib.rs index 5199b4a..15c99b8 100644 --- a/exercises/03_ticket_v1/12_outro/src/lib.rs +++ b/exercises/03_ticket_v1/12_outro/src/lib.rs @@ -1,6 +1,6 @@ // TODO: Define a new `Order` type. // It should keep track of three pieces of information: `product_name`, `quantity`, and `unit_price`. -// The product name can't be empty and it can't be longer than 300 characters. +// The product name can't be empty and it can't be longer than 300 bytes. // The quantity must be strictly greater than zero. // The unit price is in cents and must be strictly greater than zero. // Order must include a method named `total` that returns the total price of the order. diff --git a/exercises/04_traits/05_str_slice/src/lib.rs b/exercises/04_traits/05_str_slice/src/lib.rs index a746733..5bf6614 100644 --- a/exercises/04_traits/05_str_slice/src/lib.rs +++ b/exercises/04_traits/05_str_slice/src/lib.rs @@ -12,13 +12,13 @@ impl Ticket { panic!("Title cannot be empty"); } if title.len() > 50 { - panic!("Title cannot be longer than 50 characters"); + panic!("Title cannot be longer than 50 bytes"); } if description.is_empty() { panic!("Description cannot be empty"); } if description.len() > 500 { - panic!("Description cannot be longer than 500 characters"); + panic!("Description cannot be longer than 500 bytes"); } if status != "To-Do" && status != "In Progress" && status != "Done" { panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed"); diff --git a/exercises/05_ticket_v2/01_enum/src/lib.rs b/exercises/05_ticket_v2/01_enum/src/lib.rs index ab3c5d9..a3d9592 100644 --- a/exercises/05_ticket_v2/01_enum/src/lib.rs +++ b/exercises/05_ticket_v2/01_enum/src/lib.rs @@ -20,13 +20,13 @@ impl Ticket { panic!("Title cannot be empty"); } if title.len() > 50 { - panic!("Title cannot be longer than 50 characters"); + panic!("Title cannot be longer than 50 bytes"); } if description.is_empty() { panic!("Description cannot be empty"); } if description.len() > 500 { - panic!("Description cannot be longer than 500 characters"); + panic!("Description cannot be longer than 500 bytes"); } if status != "To-Do" && status != "In Progress" && status != "Done" { panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed"); diff --git a/exercises/05_ticket_v2/03_variants_with_data/src/lib.rs b/exercises/05_ticket_v2/03_variants_with_data/src/lib.rs index c3943fe..03faf0c 100644 --- a/exercises/05_ticket_v2/03_variants_with_data/src/lib.rs +++ b/exercises/05_ticket_v2/03_variants_with_data/src/lib.rs @@ -22,13 +22,13 @@ impl Ticket { panic!("Title cannot be empty"); } if title.len() > 50 { - panic!("Title cannot be longer than 50 characters"); + panic!("Title cannot be longer than 50 bytes"); } if description.is_empty() { panic!("Description cannot be empty"); } if description.len() > 500 { - panic!("Description cannot be longer than 500 characters"); + panic!("Description cannot be longer than 500 bytes"); } Ticket { diff --git a/exercises/05_ticket_v2/05_nullability/src/lib.rs b/exercises/05_ticket_v2/05_nullability/src/lib.rs index 6137c65..f4e5cb2 100644 --- a/exercises/05_ticket_v2/05_nullability/src/lib.rs +++ b/exercises/05_ticket_v2/05_nullability/src/lib.rs @@ -20,13 +20,13 @@ impl Ticket { panic!("Title cannot be empty"); } if title.len() > 50 { - panic!("Title cannot be longer than 50 characters"); + panic!("Title cannot be longer than 50 bytes"); } if description.is_empty() { panic!("Description cannot be empty"); } if description.len() > 500 { - panic!("Description cannot be longer than 500 characters"); + panic!("Description cannot be longer than 500 bytes"); } Ticket { diff --git a/exercises/05_ticket_v2/06_fallibility/src/lib.rs b/exercises/05_ticket_v2/06_fallibility/src/lib.rs index 42d9f76..3144bee 100644 --- a/exercises/05_ticket_v2/06_fallibility/src/lib.rs +++ b/exercises/05_ticket_v2/06_fallibility/src/lib.rs @@ -21,13 +21,13 @@ impl Ticket { panic!("Title cannot be empty"); } if title.len() > 50 { - panic!("Title cannot be longer than 50 characters"); + panic!("Title cannot be longer than 50 bytes"); } if description.is_empty() { panic!("Description cannot be empty"); } if description.len() > 500 { - panic!("Description cannot be longer than 500 characters"); + panic!("Description cannot be longer than 500 bytes"); } Ticket { @@ -59,13 +59,13 @@ mod tests { fn title_cannot_be_longer_than_fifty_chars() { let error = Ticket::new(overly_long_title(), valid_description(), Status::ToDo).unwrap_err(); - assert_eq!(error, "Title cannot be longer than 50 characters"); + assert_eq!(error, "Title cannot be longer than 50 bytes"); } #[test] fn description_cannot_be_longer_than_500_chars() { let error = Ticket::new(valid_title(), overly_long_description(), Status::ToDo).unwrap_err(); - assert_eq!(error, "Description cannot be longer than 500 characters"); + assert_eq!(error, "Description cannot be longer than 500 bytes"); } } diff --git a/exercises/05_ticket_v2/07_unwrap/src/lib.rs b/exercises/05_ticket_v2/07_unwrap/src/lib.rs index 0a7c158..4b6419b 100644 --- a/exercises/05_ticket_v2/07_unwrap/src/lib.rs +++ b/exercises/05_ticket_v2/07_unwrap/src/lib.rs @@ -25,13 +25,13 @@ impl Ticket { return Err("Title cannot be empty".to_string()); } if title.len() > 50 { - return Err("Title cannot be longer than 50 characters".to_string()); + return Err("Title cannot be longer than 50 bytes".to_string()); } if description.is_empty() { return Err("Description cannot be empty".to_string()); } if description.len() > 500 { - return Err("Description cannot be longer than 500 characters".to_string()); + return Err("Description cannot be longer than 500 bytes".to_string()); } Ok(Ticket { @@ -60,7 +60,7 @@ mod tests { } #[test] - #[should_panic(expected = "Title cannot be longer than 50 characters")] + #[should_panic(expected = "Title cannot be longer than 50 bytes")] fn title_cannot_be_longer_than_fifty_chars() { easy_ticket(overly_long_title(), valid_description(), Status::ToDo); } diff --git a/exercises/05_ticket_v2/08_error_enums/src/lib.rs b/exercises/05_ticket_v2/08_error_enums/src/lib.rs index 5fd4252..c74fcc9 100644 --- a/exercises/05_ticket_v2/08_error_enums/src/lib.rs +++ b/exercises/05_ticket_v2/08_error_enums/src/lib.rs @@ -35,13 +35,13 @@ impl Ticket { return Err("Title cannot be empty".to_string()); } if title.len() > 50 { - return Err("Title cannot be longer than 50 characters".to_string()); + return Err("Title cannot be longer than 50 bytes".to_string()); } if description.is_empty() { return Err("Description cannot be empty".to_string()); } if description.len() > 500 { - return Err("Description cannot be longer than 500 characters".to_string()); + return Err("Description cannot be longer than 500 bytes".to_string()); } Ok(Ticket { @@ -70,7 +70,7 @@ mod tests { } #[test] - #[should_panic(expected = "Title cannot be longer than 50 characters")] + #[should_panic(expected = "Title cannot be longer than 50 bytes")] fn title_cannot_be_longer_than_fifty_chars() { easy_ticket(overly_long_title(), valid_description(), Status::ToDo); } diff --git a/exercises/05_ticket_v2/09_error_trait/src/lib.rs b/exercises/05_ticket_v2/09_error_trait/src/lib.rs index 3927775..68b5769 100644 --- a/exercises/05_ticket_v2/09_error_trait/src/lib.rs +++ b/exercises/05_ticket_v2/09_error_trait/src/lib.rs @@ -43,7 +43,7 @@ impl Ticket { } if title.len() > 50 { return Err(TicketNewError::TitleError( - "Title cannot be longer than 50 characters".to_string(), + "Title cannot be longer than 50 bytes".to_string(), )); } if description.is_empty() { @@ -53,7 +53,7 @@ impl Ticket { } if description.len() > 500 { return Err(TicketNewError::DescriptionError( - "Description cannot be longer than 500 characters".to_string(), + "Description cannot be longer than 500 bytes".to_string(), )); } @@ -84,7 +84,7 @@ mod tests { } #[test] - #[should_panic(expected = "Title cannot be longer than 50 characters")] + #[should_panic(expected = "Title cannot be longer than 50 bytes")] fn title_cannot_be_longer_than_fifty_chars() { easy_ticket(overly_long_title(), valid_description(), Status::ToDo); } diff --git a/exercises/05_ticket_v2/12_thiserror/src/lib.rs b/exercises/05_ticket_v2/12_thiserror/src/lib.rs index 97ad2b3..9289143 100644 --- a/exercises/05_ticket_v2/12_thiserror/src/lib.rs +++ b/exercises/05_ticket_v2/12_thiserror/src/lib.rs @@ -71,7 +71,7 @@ mod tests { #[test] fn title_cannot_be_longer_than_fifty_chars() { let err = Ticket::new(overly_long_title(), valid_description(), Status::ToDo).unwrap_err(); - assert_eq!(err.to_string(), "Title cannot be longer than 50 characters"); + assert_eq!(err.to_string(), "Title cannot be longer than 50 bytes"); } #[test] @@ -79,7 +79,7 @@ mod tests { let err = Ticket::new(valid_title(), overly_long_description(), Status::ToDo).unwrap_err(); assert_eq!( err.to_string(), - "Description cannot be longer than 500 characters" + "Description cannot be longer than 500 bytes" ); } } diff --git a/exercises/05_ticket_v2/14_source/src/lib.rs b/exercises/05_ticket_v2/14_source/src/lib.rs index 7c3b2c4..9f7cce5 100644 --- a/exercises/05_ticket_v2/14_source/src/lib.rs +++ b/exercises/05_ticket_v2/14_source/src/lib.rs @@ -17,11 +17,11 @@ mod status; pub enum TicketNewError { #[error("Title cannot be empty")] TitleCannotBeEmpty, - #[error("Title cannot be longer than 50 characters")] + #[error("Title cannot be longer than 50 bytes")] TitleTooLong, #[error("Description cannot be empty")] DescriptionCannotBeEmpty, - #[error("Description cannot be longer than 500 characters")] + #[error("Description cannot be longer than 500 bytes")] DescriptionTooLong, } diff --git a/exercises/05_ticket_v2/15_outro/src/description.rs b/exercises/05_ticket_v2/15_outro/src/description.rs index 2f9dbd1..ecf55ad 100644 --- a/exercises/05_ticket_v2/15_outro/src/description.rs +++ b/exercises/05_ticket_v2/15_outro/src/description.rs @@ -1,5 +1,5 @@ // TODO: Implement `TryFrom` and `TryFrom<&str>` for the `TicketDescription` type, -// enforcing that the description is not empty and is not longer than 500 characters. +// enforcing that the description is not empty and is not longer than 500 bytes. // Implement the traits required to make the tests pass too. pub struct TicketDescription(String); @@ -27,7 +27,7 @@ mod tests { let err = TicketDescription::try_from(description).unwrap_err(); assert_eq!( err.to_string(), - "The description cannot be longer than 500 characters" + "The description cannot be longer than 500 bytes" ); } diff --git a/exercises/05_ticket_v2/15_outro/src/title.rs b/exercises/05_ticket_v2/15_outro/src/title.rs index 5ee99c9..cb31996 100644 --- a/exercises/05_ticket_v2/15_outro/src/title.rs +++ b/exercises/05_ticket_v2/15_outro/src/title.rs @@ -27,10 +27,7 @@ mod tests { "A title that's definitely longer than what should be allowed in a development ticket" .to_string(); let err = TicketTitle::try_from(title).unwrap_err(); - assert_eq!( - err.to_string(), - "The title cannot be longer than 50 characters" - ); + assert_eq!(err.to_string(), "The title cannot be longer than 50 bytes"); } #[test] diff --git a/helpers/ticket_fields/src/description.rs b/helpers/ticket_fields/src/description.rs index 55cf37f..c06d4f4 100644 --- a/helpers/ticket_fields/src/description.rs +++ b/helpers/ticket_fields/src/description.rs @@ -5,7 +5,7 @@ pub struct TicketDescription(String); pub enum TicketDescriptionError { #[error("The description cannot be empty")] Empty, - #[error("The description cannot be longer than 500 characters")] + #[error("The description cannot be longer than 500 bytes")] TooLong, } @@ -61,7 +61,7 @@ mod tests { let err = TicketDescription::try_from(overly_long_description()).unwrap_err(); assert_eq!( err.to_string(), - "The description cannot be longer than 500 characters" + "The description cannot be longer than 500 bytes" ); } diff --git a/helpers/ticket_fields/src/title.rs b/helpers/ticket_fields/src/title.rs index 152e919..3687a5b 100644 --- a/helpers/ticket_fields/src/title.rs +++ b/helpers/ticket_fields/src/title.rs @@ -7,7 +7,7 @@ pub struct TicketTitle(String); pub enum TicketTitleError { #[error("The title cannot be empty")] Empty, - #[error("The title cannot be longer than 50 characters")] + #[error("The title cannot be longer than 50 bytes")] TooLong, } @@ -61,10 +61,7 @@ mod tests { #[test] fn test_try_from_long_string() { let err = TicketTitle::try_from(overly_long_title()).unwrap_err(); - assert_eq!( - err.to_string(), - "The title cannot be longer than 50 characters" - ); + assert_eq!(err.to_string(), "The title cannot be longer than 50 bytes"); } #[test]