Hi all, i'm new to rust, and i'm not very skilled with it's features.
I've tried to use curl::Easy, but i'm unable to understand what this code do.
The original code from tutorial ;
extern crate curl;
use curl::easy::Easy;
// Capture output into a local `Vec`.
fn main() {
let mut dst = Vec::new();
let mut easy = Easy::new();
easy.url("https://www.rust-lang.org/").unwrap();
let mut transfer = easy.transfer();
transfer.write_function(|data| {
dst.extend_from_slice(data);
Ok(data.len())
}).unwrap();
transfer.perform().unwrap();
}
I've modified the code in this way ;
extern crate curl;
use curl::easy::Easy;
// Capture output into a local `Vec`.
fn main() {
let mut dst = Vec::new();
let mut easy = Easy::new();
{
easy.url("https://www.rust-lang.org/").unwrap();
let mut transfer = easy.transfer();
transfer.write_function(|data| {
dst.extend_from_slice(data);
Ok(data.len())
}).unwrap();
transfer.perform().unwrap();
}
println!("{:?}", dst);
}
But the output it's only numeric, i don't understand why i cannot see the webpage splitted into element of the vector.
thanks a lot.
G.