I’m creating a terminal_io
struct which has a large number of mutable fields. Before modifying them, I want to create a copy of the struct in order to be able to restore it later. Currently I’m making a duplicate call to Unix.tcgetattr
:
let savedTio = Unix.tcgetattr Unix.stdin in
let tio = Unix.tcgetattr Unix.stdin in
I know you can create a copy with modified variables e.g. with:
let tio = Unix.tcgetattr Unix.stdin in
let savedTio = { tio with ... = ... } in
But I don’t want to modify any values.
Is there a better way to do this?