chore(native): simplify Array::get method with functional approach (#13771)

## Issue

The Array::get method used verbose nested Option handling with redundant
returns, making the code longer and less Rust idiomatic.

## Solution

Replaced the nested if let structure with a functional and_then approach
that:
- Eliminates redundant return keyword usage
- Flattens Option handling for cleaner logic
- Reduces code from 13 lines to 9 lines
- Maintains identical functionality

## Result

More idiomatic Rust code that's easier to read and maintain, with all
tests passing.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
* Improved internal code structure with functional programming patterns
for enhanced maintainability. No visible changes to end-user
functionality.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com>
This commit is contained in:
Juan Abimael Santos Castillo
2025-10-21 12:45:58 -04:00
committed by GitHub
parent c2fb6adfd8
commit 6fb0ff9177
@@ -36,15 +36,13 @@ impl Array {
pub fn get(&self, index: u64) -> Option<Value> {
let (item, offset) = self.get_item_at(index)?;
if let Some(item) = item.get() {
item.get().and_then(|item| {
// TODO: rewrite to content.read(&mut [Any])
return match &item.content {
Content::Any(any) => return any.get(offset as usize).map(|any| Value::Any(any.clone())),
match &item.content {
Content::Any(any) => any.get(offset as usize).map(|any| Value::Any(any.clone())),
_ => Some(Value::from(&item.content)),
};
}
None
}
})
}
pub fn iter(&self) -> ArrayIter {