# Unsafe Rust (Rust) > Blocos unsafe, raw pointers (*const T, *mut T), FFI, unsafe traits, Undefined Behavior (UB), invariantes de safety - 20 perguntas de entrevista - Senior - [Perguntas de entrevista: Rust](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista.md) ## 1. Qual palavra-chave habilita os superpoderes do modo unsafe em Rust? **Resposta** A palavra-chave unsafe desbloqueia cinco capacidades proibidas no safe Rust: desreferenciar raw pointers, chamar funções unsafe, acessar variáveis estáticas mutáveis, implementar unsafe traits e acessar campos de unions. Esse bloco sinaliza ao compilador que o desenvolvedor assume a responsabilidade de garantir a memory safety. ## 2. Quantas capacidades adicionais o código unsafe libera em comparação com o safe Rust? **Resposta** O modo unsafe libera exatamente cinco capacidades: desreferenciar raw pointers, chamar funções ou métodos unsafe, acessar ou modificar variáveis mutáveis estáticas, implementar traits unsafe e acessar os campos de unions. Essas cinco operações são as únicas diferenças entre safe e unsafe Rust. ## 3. Qual é a sintaxe correta para criar um raw pointer imutável para uma variável em Rust? **Resposta** A sintaxe para criar um raw pointer imutável é let ptr = &x as *const T. O tipo *const T representa um raw pointer imutável. Criar raw pointers é safe, somente o deref exige um bloco unsafe. Também é possível usar a coerção implícita com let ptr: *const T = &x. ## Mais 17 perguntas disponiveis - Qual é a diferença entre *const T e *mut T em Rust? - Por que criar raw pointers é permitido em safe Rust enquanto desreferenciá-los não é? Cadastre-se gratis: https://sharpskill.dev/pt/login ## Outros temas de entrevista Rust - [Fundamentos de Rust](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/rust-basics.md): 25 perguntas, Junior - [Ownership & Borrowing](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/ownership-borrowing.md): 22 perguntas, Junior - [Structs & Enums](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/structs-enums.md): 20 perguntas, Junior - [Tratamento de erros](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/error-handling.md): 18 perguntas, Junior - [Coleções](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/collections.md): 20 perguntas, Junior - [Módulos e Pacotes](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/modules-packages.md): 18 perguntas, Junior - [Traits](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/traits.md): 22 perguntas, Mid-Level - [Generics](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/generics.md): 20 perguntas, Mid-Level - [Lifetimes](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/lifetimes.md): 20 perguntas, Mid-Level - [Iterators & Closures](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/iterators-closures.md): 22 perguntas, Mid-Level - [Smart Pointers](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/smart-pointers.md): 22 perguntas, Mid-Level - [Concurrency Basics](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/concurrency-basics.md): 20 perguntas, Mid-Level - [async/await](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/async-await.md): 22 perguntas, Mid-Level - [Testing](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/testing.md): 18 perguntas, Mid-Level - [Cargo & Ecosystem](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/cargo-ecosystem.md): 18 perguntas, Mid-Level - [Pattern Matching](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/pattern-matching.md): 18 perguntas, Mid-Level - [Macros](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/macros.md): 20 perguntas, Mid-Level - [Serde e serialização](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/serde-serialization.md): 20 perguntas, Mid-Level - [Traits avançados](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/advanced-traits.md): 22 perguntas, Senior - [Lifetimes Avançados](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/advanced-lifetimes.md): 20 perguntas, Senior - [Type System](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/type-system.md): 20 perguntas, Senior - [Tokio & Async I/O](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/tokio-async.md): 22 perguntas, Senior - [Otimização de Desempenho](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/performance-optimization.md): 20 perguntas, Senior - [Memory Management](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/memory-management.md): 20 perguntas, Senior - [Web Frameworks](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/web-frameworks.md): 22 perguntas, Senior - [Database Integration](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/database-integration.md): 20 perguntas, Senior - [Padrões de design em Rust](https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/design-patterns.md): 20 perguntas, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/pt/technologies/rust/perguntas-entrevista/unsafe-rust