You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: quirks.rs
    path of file: ./repos/phaser/phaser/vendor/url/src
    
    the code of the file until where you have to start completion: // Copyright 2016 The rust-url developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Getters and setters for URL components implemented per https://url.spec.whatwg.org/#api
//!
//! Unless you need to be interoperable with web browsers,
//! you probably want to use `Url` method instead.

use crate::parser::{default_port, Context, Input, Parser, SchemeType};
use crate::{Host, ParseError, Position, Url};

/// https://url.spec.whatwg.org/#dom-url-domaintoascii
pub fn domain_to_ascii(domain: &str) -> String {
    match Host::parse(domain) {
        Ok(Host::Domain(domain)) => domain,
        _ => String::
    
pub fn set_host(url: &mut Url, new_host: &str) -> Result<(), ()> {
    // If context object’s url’s cannot-be-a-base-URL flag is set, then return.
    if url.cannot_be_a_base() {
        return Err(());
    }
    // Host parsing rules are strict,
    // We don't want to trim the input
    let input = Input::no_trim(new_host);
    let host;
    let opt_port;
    {
        let scheme = url.scheme();
        let scheme_type = SchemeType::from(scheme);
        if scheme_type == SchemeType::File && new_host.is_empty() {
            url.set_host_internal(Host::Domain(String::new()), None);
            return Ok(());
        }

        if let Ok((h, remaining)) = Parser::parse_host(input, scheme_type) {
            host = h;
            opt_port = if let Some(remaining) = remaining.split_prefix(':') {
                if remaining.is_empty() {
                    None
                } else {
                    Parser::parse_port(remaining, || default_port(scheme), Context::Setter)
                        .ok()
                        .map(|(port, _remaining)| port)
                }
            } else {
                None
            };
        } else {
            return Err(());
        }
    }
    // Make sure we won't set an empty host to a url with a username or a port
    if host == Host::Domain("".to_string()) {
        if !username(&url).is_empty() {
            return Err(());
        } else if let Some(Some(_)) = opt_port {
            return Err(());
        } else if url.port().is_some() {
            return Err(());
        }
    }
    url.set_host_internal(host, opt_port);
    Ok(())
}