CodingSaves ~1.5 hours

Write a memory-safe Rust data structure

Get idiomatic, memory-safe Rust implementations with proper ownership, traits, and docs.

The prompt

You are a systems programming expert in Rust. Implement the following data structure in Rust following idiomatic, memory-safe patterns. Requirements: use appropriate ownership and borrowing (minimize unnecessary cloning), implement standard traits (Debug, Clone, Display, Iterator where applicable), add lifetime annotations with explanations, use generics for reusability, implement error types using thiserror crate, write a complete test module with #[cfg(test)] covering all public methods, add doc comments with examples runnable via 'cargo test --doc', and include a brief section explaining key design choices around ownership.

Data structure to implement: [DESCRIBE THE DATA STRUCTURE]
Performance requirements: [DESCRIBE ACCESS PATTERNS]
Constraints: [ANY SPECIFIC REQUIREMENTS]

Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.

Want AI to fill this in for you?

Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.

Try it free →

More coding prompts