# Generics (Rust) > Generic functions, structs, enums, trait bounds, where clause, monomorphization - 20 interview questions - Mid-Level - [Interview Questions: Rust](https://sharpskill.dev/en/technologies/rust/interview-questions.md) ## 1. What is the correct syntax for declaring a generic function in Rust? **Answer** In Rust, generic type parameters are declared using angle brackets after the function name. The syntax fn name(param: T) indicates that T is a type parameter that will be determined at usage. The compiler then generates specialized code for each concrete type used when calling the function. ## 2. How to declare a generic struct with a field of type T? **Answer** A generic struct is declared with the type parameter in angle brackets after the struct name. The syntax struct Name { field: T } allows creating a reusable structure with different types. The type T can then be used in fields and methods associated with this struct. ## 3. What is monomorphization in Rust? **Answer** Monomorphization is the process by which the Rust compiler generates specialized machine code for each concrete type used with a generic. For example, if a generic function is called with i32 and String, the compiler creates two distinct versions of that function. This ensures optimal performance without runtime overhead. ## 17 more questions available - How to add a trait bound on a generic parameter T? - What is the difference between impl Struct and impl Struct syntax? Sign up for free: https://sharpskill.dev/en/login ## Other Rust interview topics - [Rust Basics](https://sharpskill.dev/en/technologies/rust/interview-questions/rust-basics.md): 25 questions, Junior - [Ownership & Borrowing](https://sharpskill.dev/en/technologies/rust/interview-questions/ownership-borrowing.md): 22 questions, Junior - [Structs & Enums](https://sharpskill.dev/en/technologies/rust/interview-questions/structs-enums.md): 20 questions, Junior - [Error Handling](https://sharpskill.dev/en/technologies/rust/interview-questions/error-handling.md): 18 questions, Junior - [Collections](https://sharpskill.dev/en/technologies/rust/interview-questions/collections.md): 20 questions, Junior - [Modules & Packages](https://sharpskill.dev/en/technologies/rust/interview-questions/modules-packages.md): 18 questions, Junior - [Traits](https://sharpskill.dev/en/technologies/rust/interview-questions/traits.md): 22 questions, Mid-Level - [Lifetimes](https://sharpskill.dev/en/technologies/rust/interview-questions/lifetimes.md): 20 questions, Mid-Level - [Iterators & Closures](https://sharpskill.dev/en/technologies/rust/interview-questions/iterators-closures.md): 22 questions, Mid-Level - [Smart Pointers](https://sharpskill.dev/en/technologies/rust/interview-questions/smart-pointers.md): 22 questions, Mid-Level - [Concurrency Basics](https://sharpskill.dev/en/technologies/rust/interview-questions/concurrency-basics.md): 20 questions, Mid-Level - [async/await](https://sharpskill.dev/en/technologies/rust/interview-questions/async-await.md): 22 questions, Mid-Level - [Testing](https://sharpskill.dev/en/technologies/rust/interview-questions/testing.md): 18 questions, Mid-Level - [Cargo & Ecosystem](https://sharpskill.dev/en/technologies/rust/interview-questions/cargo-ecosystem.md): 18 questions, Mid-Level - [Pattern Matching](https://sharpskill.dev/en/technologies/rust/interview-questions/pattern-matching.md): 18 questions, Mid-Level - [Macros](https://sharpskill.dev/en/technologies/rust/interview-questions/macros.md): 20 questions, Mid-Level - [Serde & Serialization](https://sharpskill.dev/en/technologies/rust/interview-questions/serde-serialization.md): 20 questions, Mid-Level - [Unsafe Rust](https://sharpskill.dev/en/technologies/rust/interview-questions/unsafe-rust.md): 20 questions, Senior - [Advanced Traits](https://sharpskill.dev/en/technologies/rust/interview-questions/advanced-traits.md): 22 questions, Senior - [Advanced Lifetimes](https://sharpskill.dev/en/technologies/rust/interview-questions/advanced-lifetimes.md): 20 questions, Senior - [Type System](https://sharpskill.dev/en/technologies/rust/interview-questions/type-system.md): 20 questions, Senior - [Tokio & Async I/O](https://sharpskill.dev/en/technologies/rust/interview-questions/tokio-async.md): 22 questions, Senior - [Performance Optimization](https://sharpskill.dev/en/technologies/rust/interview-questions/performance-optimization.md): 20 questions, Senior - [Memory Management](https://sharpskill.dev/en/technologies/rust/interview-questions/memory-management.md): 20 questions, Senior - [Web Frameworks](https://sharpskill.dev/en/technologies/rust/interview-questions/web-frameworks.md): 22 questions, Senior - [Database Integration](https://sharpskill.dev/en/technologies/rust/interview-questions/database-integration.md): 20 questions, Senior - [Rust Design Patterns](https://sharpskill.dev/en/technologies/rust/interview-questions/design-patterns.md): 20 questions, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/en/technologies/rust/interview-questions/generics