풀이enum Shape { Circle, Square, Rectangle, Triangle, Pentagon,}impl Shape { // TODO: Implement the `n_sides` method using a `match`. pub fn n_sides(&self) -> u8 { match self { Shape::Circle => 0, Shape::Square => 4, Shape::Rectangle => 4, Shape::Triangle => 3, Shape::Pentagon => 5, } }}#[cfg(test)]mod tes..
문제// TODO: `Status`를 `Ticket::status`의 타입으로 사용하세요.// 다른 모든 메서드의 시그니처와 구현을 필요에 따라 조정하세요.#[derive(Debug, PartialEq)]// `derive`는 재귀적입니다: 모든 필드가 PartialEq를 구현해야만 PartialEq를 derive할 수 있습니다.// `Debug`도 마찬가지입니다.struct Ticket { title: String, description: String, status: String,}enum Status { // TODO: add the missing variants}impl Ticket { pub fn new(title: String, description: String, s..
풀이// TODO: Drob bomb를 구현하세요.// 불필요한 drop이 발생하면 패닉을 일으킵니다.// 요구하는 API는 테스트에서 확인할 수 있습니다.struct DropBomb { defused: bool,}impl Drop for DropBomb { fn drop(&mut self) { if !self.defused { panic!(); } }}impl DropBomb { pub fn new() -> Self{ DropBomb { defused: false, } } pub fn defuse(&mut self) { self.defused = true; }}#[..
기존 코드pub fn summary(ticket: Ticket) -> (Ticket, Summary) { (ticket, ticket.summary())}pub struct Ticket { pub title: String, pub description: String, pub status: String,}impl Ticket { pub fn summary(self) -> Summary { Summary { title: self.title, status: self.status, } }}풀이pub fn summary(ticket: Ticket) -> (Ticket, Summary) { (ticket.clone..
내 블로그 - 관리자 홈 전환 |
Q
Q
|
---|---|
새 글 쓰기 |
W
W
|
글 수정 (권한 있는 경우) |
E
E
|
---|---|
댓글 영역으로 이동 |
C
C
|
이 페이지의 URL 복사 |
S
S
|
---|---|
맨 위로 이동 |
T
T
|
티스토리 홈 이동 |
H
H
|
단축키 안내 |
Shift + /
⇧ + /
|
* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.