Sometimes we want to asynchronously update the prompt. For example, if we are using rustyline as a remote terminal, we want to display the connection info in the prompt. When disconnected, it is nicer to show a message and change the prompt to a ready state. With a Generic prompt type, it is possible to do that.
Performance overhead: in order to display the prompt, it should implement ToString trait. Therefore, it has a little performance overhead because it calls to_string every time it needs the prompt as a string (printing the prompt or calculating the cursor position). However, it is negligible as the whole system is a human interface that does not affect functionality.
Sometimes we want to asynchronously update the prompt. For example, if we are using rustyline as a remote terminal, we want to display the connection info in the prompt. When disconnected, it is nicer to show a message and change the prompt to a ready state. With a Generic prompt type, it is possible to do that.
Performance overhead: in order to display the prompt, it should implement ToString trait. Therefore, it has a little performance overhead because it calls to_string every time it needs the prompt as a string (printing the prompt or calculating the cursor position). However, it is negligible as the whole system is a human interface that does not affect functionality.