News Score: Score the News, Sort the News, Rewrite the Headlines

StackSafe: Taming Recursion in Rust Without Stack Overflow | FastLabs / Blog

TL;DR Recursive algorithms in Rust can easily cause stack overflows that crash your program: fn tree_depth(node: &TreeNode) -> usize { match node { TreeNode::Leaf => 1, TreeNode::Branch(left, right) => { 1 + tree_depth(left).max(tree_depth(right)) } }}// This panics: thread 'main' panicked at 'stack overflow'let deep_tree = create_deep_tree(100000);println!("{}", tree_depth(&deep_tree)); StackSafe solves this by automatically growing the stack in recursive f...

Read more at fast.github.io

© News Score  score the news, sort the news, rewrite the headlines