Ad
Fundamentals
Strings
Data Types
Code
Diff
  • fn minutes(mins: u32) -> String {
        format!("{}:{:02}", mins / 60, mins % 60)
    }
    • def minutes(mins):
    • return '{}:{:02}'.format(*divmod(mins, 60))
    • fn minutes(mins: u32) -> String {
    • format!("{}:{:02}", mins / 60, mins % 60)
    • }
Strings
Data Types

Take any string and return the last character.

If the string is empty, return nothing.

Code
Diff
  • fn last_char(string: &str) -> Option<char> {
        string.chars().rev().next()
    }
    • function lastChar(string) {
    • return string[string.length - 1];
    • fn last_char(string: &str) -> Option<char> {
    • string.chars().rev().next()
    • }