is ConnectionOptions.hosts work correctly?
for new version 0.2.0
pub struct ConnectionOptions {
/// List of hosts
///
/// Default: vec![Host::default()]
pub hosts: Vec<Host>,
/// Name of the database to connect to
///
/// Default: `"admin"`
pub db: String,
/// Authentication options
///
/// Default: `None`
pub auth: Option<Auth>,
}
impl Default for ConnectionOptions {
fn default() -> ConnectionOptions {
ConnectionOptions {
hosts: vec![Host::default()],
db: "admin".to_string(),
auth: None,
}
}
}
/// Builder for `ConnectionOptions`
pub struct ConnectionOptionsBuilder(ConnectionOptions);
impl ConnectionOptionsBuilder {
pub fn new() -> ConnectionOptionsBuilder {
ConnectionOptionsBuilder(ConnectionOptions::default())
}
pub fn with_host(&mut self, hostname: &str, port: u16) -> &mut ConnectionOptionsBuilder {
self.0.hosts.push(Host{
hostname: hostname.to_string(),
port
});
self
}
....
}
this code will create a default host in ConnectionOptions.hosts
, but when i call ConnectionOptionsBuilder::with_host()
the new host is just pushed, the default host is not what i want. then how to remove the default host.