terminal handling for rust