Rocket/contrib/sync_db_pools/codegen/tests/ui-fail/database-syntax.rs

55 lines
1.1 KiB
Rust
Raw Normal View History

use rocket_sync_db_pools::database;
2018-12-12 08:00:10 +00:00
struct Connection;
struct Manager;
use rocket::{Rocket, Build};
use rocket_sync_db_pools::{r2d2, Poolable, PoolResult};
impl r2d2::ManageConnection for Manager {
type Connection = Connection;
type Error = std::convert::Infallible;
fn connect(&self) -> Result<Self::Connection, Self::Error> { Ok(Connection) }
fn is_valid(&self, _: &mut Self::Connection) -> Result<(), Self::Error> { Ok(()) }
fn has_broken(&self, _: &mut Self::Connection) -> bool { true }
}
impl Poolable for Connection {
type Manager = Manager;
type Error = std::convert::Infallible;
fn pool(_: &str, _: &Rocket<Build>) -> PoolResult<Self> {
todo!()
}
}
2018-12-12 08:00:10 +00:00
#[database]
struct A(Connection);
2018-12-12 08:00:10 +00:00
#[database(1)]
struct B(Connection);
2018-12-12 08:00:10 +00:00
#[database(123)]
struct C(Connection);
2018-12-12 08:00:10 +00:00
#[database("hello" "hi")]
struct D(Connection);
2018-12-12 08:00:10 +00:00
#[database("test")]
enum Foo { }
#[database("test")]
struct Bar(Connection, Connection);
2018-12-12 08:00:10 +00:00
#[database("test")]
union Baz { }
#[database("test")]
struct E<'r>(&'r str);
#[database("test")]
struct F<T>(T);
fn main() { }