I have written several fasta parsers in Rust that look extremely similar to that - ChatGPT is great at regurgitating code thats on github! I haven't had as good luck getting it to write Rust for more complex stuff