https://ortem.xyz website source code
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.
23 lines
525 B
23 lines
525 B
+++ |
|
title = "Tricky questions for any rust interview" |
|
date = "2022-08-18" |
|
|
|
[taxonomies] |
|
tags = ["rust"] |
|
+++ |
|
|
|
Which type has variable `result`? |
|
```rust |
|
fn count_uppercase(s: &str) -> usize { |
|
let result = { |
|
let upper = s.chars().filter(|c| c.is_uppercase()).collect::<String>(); |
|
return upper.len(); |
|
}; |
|
} |
|
``` |
|
|
|
<details><summary>Answer</summary> |
|
|
|
`result` has '!' type or 'never type'. . [Read more](https://doc.rust-lang.org/book/ch19-04-advanced-types.html#the-never-type-that-never-returns) |
|
|
|
</details> |