JDK-4513622: keeping a substring of a field prevents GC for object
bugs.java.com
bugs.java.com
I'm not a rust expert, but I believe that it's basically impossible to write something like the code in the bug report without getting a compile time error in rust. You'd either need to use a version of substring that makes a copy, or explicitly keep the large strings around.