restructure based on suggestion

Co-authored-by: Bennet Bleßmann <3877590+Skgland@users.noreply.github.com>
This commit is contained in:
no382001
2026-03-31 21:13:40 +02:00
parent c065b52778
commit 28f8da5ce9

View File

@@ -657,14 +657,8 @@ impl Stream {
#[inline] #[inline]
pub fn stdin(arena: &mut Arena, add_history: bool) -> Stream { pub fn stdin(arena: &mut Arena, add_history: bool) -> Stream {
if std::io::stdin().is_terminal() {
Stream::Readline(arena_alloc!(
StreamLayout::new(ReadlineStream::new("", add_history)),
arena
))
} else {
#[cfg(unix)] #[cfg(unix)]
{ if !std::io::stdin().is_terminal() {
use std::os::unix::io::{FromRawFd, RawFd}; use std::os::unix::io::{FromRawFd, RawFd};
// dup fd 0 so the File can be owned (and closed later) without // dup fd 0 so the File can be owned (and closed later) without
// closing the real stdin. // closing the real stdin.
@@ -672,13 +666,12 @@ impl Stream {
let file = unsafe { File::from_raw_fd(fd) }; let file = unsafe { File::from_raw_fd(fd) };
return Stream::from_file_as_input(atom!("user_input"), file, arena); return Stream::from_file_as_input(atom!("user_input"), file, arena);
} }
#[allow(unreachable_code)]
Stream::Readline(arena_alloc!( Stream::Readline(arena_alloc!(
StreamLayout::new(ReadlineStream::new("", add_history)), StreamLayout::new(ReadlineStream::new("", add_history)),
arena arena
)) ))
} }
}
pub fn from_tag(tag: ArenaHeaderTag, ptr: UntypedArenaPtr) -> Self { pub fn from_tag(tag: ArenaHeaderTag, ptr: UntypedArenaPtr) -> Self {
match tag { match tag {