Rust dynamic programming : word break
My main issue with this code is the function interface as you already identified yourself. These are the most glaring issues in my opinion:


Parameter names are not clear. Names like i and n might be good enough in very short, self-contained loops/closures, but not as function parameters. I similarly don't like abbreviations like orig, and cur because the full words are not much longer. Always consider you first see this function, is it original or origin, is it current or cursor? Your interface should be clear without reading the code.
You are always passing a full string slice while you know you will only read from a certain offset (i).
Passing n is redundant, as almost any check that you do against this can be replaced by checking if you reached the end of orig.
Similarly but less obvious passing i is redundant. The obvious part is related to the first point, if you only pass the slice this represents offset 0. Now, you also use this as a cache key, but that's not necessary. If instead of passing the full slice you only push the 'remaining' string you can use this as cache key to exactly the same effect.
You insert true in the cache, which requires it to be a map, but there are several reasons why this is useless. I'd just use a HashSet that is only updated for false. Reasons are as follows:


If you found a 'true', the function finished anyway.
When indexed by usize and with this judging system you can't use the cache for multiple string inputs (and never for multiple word inputs). So the true cache is even useless here.
But even if you could re-use the cache, the true adds little, because you can quickly prune the false branches already.

You explicitly end with return false;, it is more idiomatic to simply say false (without the semicolon).
You have a whole construct that basically loops over a splitted version of your input. This can be significantly simplified by using the built-in split_at.


Based on all this I refactored your original algorithm to the following:

use std::collections::HashSet;
impl Solution {
    fn dfs(remaining: &amp;str, words: &amp;HashSet&lt;String&gt;, mut cache: &amp;mut HashSet&lt;String&gt;) -&gt; bool {
        for i in 1..remaining.len() + 1 {
            let (word, remaining) = remaining.split_at(i);
            if words.contains(word.into())
                &amp;&amp; !cache.contains(remaining.into())
                &amp;&amp; Self::dfs(remaining, &amp;words, &amp;mut cache)
            {
                return true;
            }
        }
        if remaining.len() == 0 {
            true
        } else {
            cache.insert(remaining.into());
            false
        }
    }
    pub fn word_break(s: String, word_dict: Vec&lt;String&gt;) -&gt; bool {
        let set = word_dict.into_iter().collect::&lt;HashSet&lt;String&gt;&gt;();
        let mut cache = HashSet::new();
        Self::dfs(&amp;s.as_str(), &amp;set, &amp;mut cache)
    }
}


This may not yet be ideal, I for example don't like remaining and dfs as names. Other improvements you could try but are honestly overkill for a braintease exercise:


It seems somewhat weird to pass words and cache as a parameter. More idiomatic would be to make a WordBreakChecker struct. You provide it with a new initializer that sets the cache and words, and then have a single dfs (or better check) function that only takes the string as input.
In my example I still index the slice explicitly by using a for loop and split_at. That's good enough for here, but it may be interesting practice to implement the Iterator trait to iterate over these combinations directly (honestly, it may exist already in std or a crate, I didn't look to hard).