Skip to content
Discussion options

You must be logged in to vote

Great question! The core goal of tinyxml2-rs is to provide that memory-safe environment without losing the familiarity of the TinyXML2 API.
You do not need to perform manual nullptr checks. The Rust implementation completely abstracts away raw pointers on the user-facing side by leveraging Rust's Option<T> enum.
If an element exists, it returns Some(Element). If it doesn't, it returns None.
Here is how you handle it idiomatically in your Rust codebase:

// Instead of: if (element != nullptr) { ... }

// Approach 1: Using if let (Recommended for simple checks)
if let Some(child) = node.first_child_element("my_tag") {
    println!("Found element: {}", child.name());
} else {
    println!("El…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Umarahsan321
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants