Ad
Strings
Data Types

Return the last character from a string.

In Rust return an Option<char>.

Code
Diff
  • fn last_char(string: &str) -> Option<char> {
        string.chars().last()
    }
    • fn last_char(string: &str) -> Option<char> {
    • string.chars().rev().next()
    • string.chars().last()
    • }