January 2019
Intermediate to advanced
520 pages
14h 32m
English
Now, we can replace our Connection instance from the postgres crate with Conn from the mysql crate to provide our interaction functions. The first function, create_table, uses a mutable reference to a Conn instance:
fn create_table(conn: &mut Conn) -> Result<(), Error> { conn.query("CREATE TABLE users ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL, email VARCHAR(50) NOT NULL )") .map(drop)}
Also, we used the query method of the Conn connection object to send a query. This method doesn't expect parameters. We still ignore the successful result of a query and drop it with map.
The next function, create_user, has transformed into the following form:
fn create_user(conn: &mut Conn, user: ...
Read now
Unlock full access