Rust mysql pool constructor

Why does this code not work:

use super::*;

use mysql;

#[test]
fn test_00() {
    let pool = mysql::Pool::new(mysql::Opts::from(
        &mysql::OptsBuilder::new()
            .ip_or_hostname(Some("127.0.0.1"))
            .user(Some("user"))
            .pass(Some("pass".to_string())),
    ))
    .unwrap();
}

OptsBuilder::new() has .ip_or_hostname, .user, and .pass

Furthermore, Opts implments From<OptsBuilder>

What am I doing wrong?

Hmm, apparently the solution is:

    let mut builder = OptsBuilder::new();
    builder
        .ip_or_hostname(Some("127.0.0.1"))
        .user(Some("user"))
        .pass(Some("pass".to_string()));

    let pool = Pool::new(builder).unwrap();

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.