You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Augusto 473ff15a20 Add subject and test for exercise `roman_numbers_iter` 3 years ago
..
README.md Add subject and test for exercise `roman_numbers_iter` 3 years ago

README.md

roman_numbers_iter

Instructions

Implement the IntoIterator trait for the RomanNumber type to enable using a for loop notation. This implementation must allow taking ownership, borrowing and borrowing mutably

  1. Taking ownership (this consumes the RomanNumber)
for digit in number {
	...
}
  1. Borrowing immutably (this preserves the RomanNumber)
	for digit in &number {

	}
  1. Borrowing mutably (this allow you to modify the RomanNumber without having to return the ownership)
	for digit in &mut number {

	}

Notions

Expected Functions

use roman_numbers::{RomanDigit, RomanNumber};

impl IntoIterator for &RomanNumber {
}

impl IntoIterator for &mut RomanNumber {
}

impl IntoIterator for RomanNumber {
}

Usage

Here is a program to test your function.

use roman_numbers::RomanNumber;

fn main() {
	let number = RomanNumber::from(15);

	for digit in &number {
		println!("{:?}", digit);
	}
	println!("{:?}", number);
}

And its output

student@ubuntu:~/[[ROOT]]/test$ cargo run
RomanNumber([X, X, X, I, I])
RomanNumber([I, X])
RomanNumber([X, L, V])
RomanNumber([Nulla])
student@ubuntu:~/[[ROOT]]/test$