In this challenge, you will use Rust's pattern matching capabilities to determine the name of a weekday given its corresponding number. Each day of the week will be represented by a number from 1 to 7, where 1 corresponds to Monday and 7 corresponds to Sunday.

This is a common task that can be very useful in various applications, such as scheduling systems or calendar utilities. You will practice working with Rust's match statement to map numbers to their respective weekdays.

Your task is to implement a function, weekday_from_number(day: u8) -> &'static str, that takes a number as input and returns the corresponding weekday as a string. If the input number is not within the range of 1 to 7, the function should return "Invalid day number".

Use the match statement to map each number to its corresponding weekday.

Remember that Rust strings are UTF-8 encoded and &'static str denotes a string slice that lives for the entire duration of the program

Editor not available on Mobile!

In order to solve the challenge, please visit this page on a desktop computer.

Weekday from Number

In this challenge, you will use Rust's pattern matching capabilities to determine the name of a weekday given its corresponding number. Each day of the week will be represented by a number from 1 to 7, where 1 corresponds to Monday and 7 corresponds to Sunday.

This is a common task that can be very useful in various applications, such as scheduling systems or calendar utilities. You will practice working with Rust's match statement to map numbers to their respective weekdays.

Your task is to implement a function, weekday_from_number(day: u8) -> &'static str, that takes a number as input and returns the corresponding weekday as a string. If the input number is not within the range of 1 to 7, the function should return "Invalid day number".