Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

rust
character
uppercase
communitycreator

What is character.to_uppercase() in Rust?

okwudili onyejiaku

Overview

to_uppercase() is a method of the character data type in Rust. It converts a character to its uppercase version. Similar methods are also present in other programming languages.

Syntax

character.to_uppercase()
Syntax for to_uppercase() method in Rust

Parameters

character: This is the character that we want to convert to uppercase.

Return value

The value returned is the uppercase version of character.

Example

fn main(){
  // create some characters
  let char1 = 'r';
  let char2 = 'u';
  let char3 = 's';
  let char4 = 't';

  // convert characters to uppercase
  println!("{}", char1.to_uppercase()); 
  println!("{}", char2.to_uppercase());  
  println!("{}", char3.to_uppercase());  
  println!("{}", char4.to_uppercase());  
}
Convert characters to uppercase in Rust programming language

Explanation

  • Lines 2–6: We create different alphabetical characters.
  • Lines 9–12: With the help of the to_uppercase() method, we convert the characters to uppercase and print them to the console screen.

RELATED TAGS

rust
character
uppercase
communitycreator
RELATED COURSES

View all Courses

Keep Exploring