Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jira-wip/src/koans/01_ticket/03_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ struct Ticket {
/// We will learn a better way to handle recoverable errors such as this one further along,
/// but let's rely on panic for the time being.
fn create_ticket(title: String, description: String, status: Status) -> Ticket {
todo!()
}
todo!()
}

#[cfg(test)]
mod tests {
Expand Down
4 changes: 2 additions & 2 deletions jira-wip/src/koans/01_ticket/05_ownership.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ impl Ticket {
/// If you are asking yourself why we are returning &str instead of &String, check out:
/// https://blog.thoughtram.io/string-vs-str-in-rust/
pub fn description(__) -> __ {
todo!()
}
todo!()
}

pub fn status(__) -> __ {
todo!()
Expand Down
12 changes: 6 additions & 6 deletions jira-wip/src/koans/01_ticket/08_recap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ pub struct Ticket {

impl Ticket {
pub fn title(&self) -> &String {
&self.title
}
&self.title
}

pub fn description(&self) -> &String {
&self.description
}
&self.description
}

pub fn status(&self) -> &Status {
&self.status
}
&self.status
}
}

pub fn create_ticket(title: String, description: String, status: Status) -> Ticket {
Expand Down
8 changes: 4 additions & 4 deletions jira-wip/src/koans/02_ticket_store/01_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ impl TicketStore {
/// We take `&mut self` because we will have to mutate our HashMap to insert a new
/// key-value pair.
pub fn save(&mut self, ticket: Ticket, id: u32) {
todo!()
}
todo!()
}

pub fn get(&self, id: &u32) -> &Ticket {
todo!()
}
todo!()
}
}

#[cfg(test)]
Expand Down
8 changes: 4 additions & 4 deletions jira-wip/src/koans/02_ticket_store/02_option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ impl TicketStore {
}

pub fn save(&mut self, ticket: Ticket, id: u32) {
self.data.insert(id, ticket);
}
self.data.insert(id, ticket);
}

/// Trying to implement `get` in the previous koan might have caused you some issues due
/// to a signature mismatch: `get` on a HashMap returns an `Option<&Ticket>`,
Expand Down Expand Up @@ -48,8 +48,8 @@ impl TicketStore {
/// For more details on `Option`, there is an exhaustive introduction in the Rust book:
/// https://doc.rust-lang.org/1.29.0/book/2018-edition/ch06-01-defining-an-enum.html#the-option-enum-and-its-advantages-over-null-values
pub fn get(&self, id: &u32) -> Option<&Ticket> {
todo!()
}
todo!()
}
}

#[cfg(test)]
Expand Down
8 changes: 4 additions & 4 deletions jira-wip/src/koans/02_ticket_store/03_id_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ impl TicketStore {
}

pub fn get(&self, id: &TicketId) -> Option<&Ticket> {
self.data.get(id)
}
self.data.get(id)
}

fn generate_id(__) -> TicketId {
todo!()
}
todo!()
}
}

#[cfg(test)]
Expand Down
24 changes: 12 additions & 12 deletions jira-wip/src/koans/02_ticket_store/04_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ impl TicketStore {
}

pub fn get(&self, id: &TicketId) -> Option<&Ticket> {
self.data.get(id)
}
self.data.get(id)
}

fn generate_id(&mut self) -> TicketId {
self.current_id += 1;
Expand All @@ -54,26 +54,26 @@ pub struct Ticket {

impl Ticket {
pub fn title(&self) -> &String {
&self.title
}
&self.title
}

pub fn description(&self) -> &String {
&self.description
}
&self.description
}

pub fn status(&self) -> &Status {
&self.status
}
&self.status
}

// The datetime when the ticket was saved in the store, if it was saved.
pub fn created_at(&self) -> __ {
todo!()
}
todo!()
}

// The id associated with the ticket when it was saved in the store, if it was saved.
pub fn id(&self) -> __ {
todo!()
}
todo!()
}
}

pub fn create_ticket(title: String, description: String, status: Status) -> Ticket {
Expand Down
4 changes: 2 additions & 2 deletions jira-wip/src/koans/02_ticket_store/05_type_as_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ impl TicketStore {
}

pub fn get(&self, id: &TicketId) -> Option<&Ticket> {
self.data.get(id)
}
self.data.get(id)
}

fn generate_id(&mut self) -> TicketId {
self.current_id += 1;
Expand Down
36 changes: 18 additions & 18 deletions jira-wip/src/koans/02_ticket_store/06_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ pub struct TicketDraft {

impl TicketDraft {
pub fn title(&self) -> &String {
&self.title
}
&self.title
}
pub fn description(&self) -> &String {
&self.description
}
&self.description
}

pub fn new(title: String, description: String) -> Result<TicketDraft, ValidationError> {
if title.is_empty() {
Expand Down Expand Up @@ -89,8 +89,8 @@ impl Error for ValidationError {}

impl std::fmt::Display for ValidationError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.0)
}
write!(f, "{}", self.0)
}
}

#[derive(Debug, Clone, PartialEq)]
Expand Down Expand Up @@ -129,8 +129,8 @@ impl TicketStore {
}

pub fn get(&self, id: &TicketId) -> Option<&Ticket> {
self.data.get(id)
}
self.data.get(id)
}

fn generate_id(&mut self) -> TicketId {
self.current_id += 1;
Expand All @@ -140,20 +140,20 @@ impl TicketStore {

impl Ticket {
pub fn title(&self) -> &String {
&self.title
}
&self.title
}
pub fn description(&self) -> &String {
&self.description
}
&self.description
}
pub fn status(&self) -> &Status {
&self.status
}
&self.status
}
pub fn created_at(&self) -> &DateTime<Utc> {
&self.created_at
}
&self.created_at
}
pub fn id(&self) -> &TicketId {
&self.id
}
&self.id
}
}

#[cfg(test)]
Expand Down
36 changes: 18 additions & 18 deletions jira-wip/src/koans/02_ticket_store/07_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ impl TicketStore {
}

pub fn get(&self, id: &TicketId) -> Option<&Ticket> {
self.data.get(id)
}
self.data.get(id)
}

/// List will return a `Vec`.
/// Check the Rust book for a primer: https://doc.rust-lang.org/book/ch08-01-vectors.html
Expand All @@ -60,11 +60,11 @@ pub struct TicketDraft {

impl TicketDraft {
pub fn title(&self) -> &String {
&self.title
}
&self.title
}
pub fn description(&self) -> &String {
&self.description
}
&self.description
}

pub fn new(title: String, description: String) -> Result<TicketDraft, ValidationError> {
if title.is_empty() {
Expand Down Expand Up @@ -93,8 +93,8 @@ impl Error for ValidationError {}

impl std::fmt::Display for ValidationError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.0)
}
write!(f, "{}", self.0)
}
}

#[derive(Debug, Clone, PartialEq)]
Expand All @@ -108,20 +108,20 @@ pub struct Ticket {

impl Ticket {
pub fn title(&self) -> &String {
&self.title
}
&self.title
}
pub fn description(&self) -> &String {
&self.description
}
&self.description
}
pub fn status(&self) -> &Status {
&self.status
}
&self.status
}
pub fn created_at(&self) -> &DateTime<Utc> {
&self.created_at
}
&self.created_at
}
pub fn id(&self) -> &TicketId {
&self.id
}
&self.id
}
}

#[cfg(test)]
Expand Down
Loading