@@ -192,6 +192,10 @@ impl FileDescription for NullOutput {
192192pub struct FileDescriptor ( Rc < RefCell < Box < dyn FileDescription > > > ) ;
193193
194194impl FileDescriptor {
195+ fn new ( fd : impl FileDescription ) -> Self {
196+ FileDescriptor ( Rc :: new ( RefCell :: new ( Box :: new ( fd) ) ) )
197+ }
198+
195199 pub fn borrow ( & self ) -> Ref < ' _ , dyn FileDescription > {
196200 Ref :: map ( self . 0 . borrow ( ) , |fd| fd. as_ref ( ) )
197201 }
@@ -239,14 +243,14 @@ impl FdTable {
239243 fds
240244 }
241245
242- /// Insert a file descriptor to the FdTable.
243- pub fn insert_fd < T : FileDescription > ( & mut self , fd : T ) -> i32 {
244- let file_handle = FileDescriptor ( Rc :: new ( RefCell :: new ( Box :: new ( fd ) ) ) ) ;
246+ /// Insert a new file description to the FdTable.
247+ pub fn insert_fd ( & mut self , fd : impl FileDescription ) -> i32 {
248+ let file_handle = FileDescriptor :: new ( fd ) ;
245249 self . insert_fd_with_min_fd ( file_handle, 0 )
246250 }
247251
248252 /// Insert a new FD that is at least `min_fd`.
249- pub fn insert_fd_with_min_fd ( & mut self , file_handle : FileDescriptor , min_fd : i32 ) -> i32 {
253+ fn insert_fd_with_min_fd ( & mut self , file_handle : FileDescriptor , min_fd : i32 ) -> i32 {
250254 // Find the lowest unused FD, starting from min_fd. If the first such unused FD is in
251255 // between used FDs, the find_map combinator will return it. If the first such unused FD
252256 // is after all other used FDs, the find_map combinator will return None, and we will use
0 commit comments