FTP: Difference between revisions

Content added Content deleted
(→‎{{header|Ruby}}: added comment)
(Added Rust)
Line 656: Line 656:
end</lang>
end</lang>
The connection is closed automatically at the end of the block.
The connection is closed automatically at the end of the block.

=={{header|Rust}}==
<lang Rust>use std::{error::Error, fs::File, io::copy};
use ftp::FtpStream;

fn main() -> Result<(), Box<dyn Error>> {
let mut ftp = FtpStream::connect("ftp.easynet.fr:21")?;
ftp.login("anonymous", "")?;
ftp.cwd("debian")?;
for file in ftp.list(None)? {
println!("{}", file);
}
let mut stream = ftp.get("README")?;
let mut file = File::create("README")?;
copy(&mut stream, &mut file)?;
Ok(())
}</lang>


=={{header|Scala}}==
=={{header|Scala}}==