pub fn parse(statement: &str) -> Result<ParseResult> {
    let input = CString::new(statement)?;
    let result = unsafe { pg_query_parse_protobuf(input.as_ptr()) };
    let parse_result = if !result.error.is_null() {
        let message = unsafe { CStr::from_ptr((*result.error).message) }.to_string_lossy().to_string();
        Err(Error::Parse(message))
    } else {
        let data = unsafe { std::slice::from_raw_parts(result.parse_tree.data as *const u8, result.parse_tree.len as usize) };
        let stderr = unsafe { CStr::from_ptr(result.stderr_buffer) }.to_string_lossy().to_string();
        protobuf::ParseResult::decode(data).map_err(Error::Decode).and_then(|result| Ok(ParseResult::new(result, stderr)))
    };
    unsafe { pg_query_free_protobuf_parse_result(result) };
    parse_result
}
/// Parses the given SQL statement into the given abstract syntax tree.
///
/// # Example
///
/// ```rust
/// use pg_query::{Node, NodeEnum, NodeRef};
///
/// let result = pg_query::parse("SELECT * FROM contacts");
/// assert!(result.is_ok());
/// let result = result.unwrap();
/// assert_eq!(result.tables(), vec!["contacts"]);
/// assert!(matches!(result.protobuf.nodes()[0].0, NodeRef::SelectStmt(_)));
/// ```
Parses the given SQL statement into the given abstract syntax tree.
Parses the given SQL statement into the given abstract syntax tree .
pub fn parse(statement: &str) -> Result<ParseResult> {
    let input = CString::new(statement)?;
    let result = unsafe { pg_query_parse_protobuf(input.as_ptr()) };
    let parse_result = if !result.error.is_null() {
        let message = unsafe { CStr::from_ptr((*result.error).message) }.to_string_lossy().to_string();
        Err(Error::Parse(message))
    } else {
        let data = unsafe { std::slice::from_raw_parts(result.parse_tree.data as *const u8, result.parse_tree.len as usize) };
        let stderr = unsafe { CStr::from_ptr(result.stderr_buffer) }.to_string_lossy().to_string();
        protobuf::ParseResult::decode(data).map_err(Error::Decode).and_then(|result| Ok(ParseResult::new(result, stderr)))
    };
    unsafe { pg_query_free_protobuf_parse_result(result) };
    parse_result
}
pub fn parse ( statement : & str ) -> Result < ParseResult > { let input = CString :: new ( statement ) ? ; let result = unsafe { pg_query_parse_protobuf ( input . as_ptr ( ) ) } ; let parse_result = if ! result . error . is_null ( ) { let message = unsafe { CStr :: from_ptr ( ( * result . error ) . message ) } . to_string_lossy ( ) . to_string ( ) ; Err ( Error :: Parse ( message ) ) } else { let data = unsafe { std :: slice :: from_raw_parts ( result . parse_tree . data as * const u8 , result . parse_tree . len as usize ) } ; let stderr = unsafe { CStr :: from_ptr ( result . stderr_buffer ) } . to_string_lossy ( ) . to_string ( ) ; protobuf :: ParseResult :: decode ( data ) . map_err ( Error :: Decode ) . and_then ( | result | Ok ( ParseResult :: new ( result , stderr ) ) ) } ; unsafe { pg_query_free_protobuf_parse_result ( result ) } ; parse_result }
Parses the given SQL statement into the given abstract syntax tree.
Parses the given SQL statement into the given abstract syntax tree .
statement
&str
statement
&str
example
```rust
use pg_query::{Node, NodeEnum, NodeRef}.

let result = pg_query::parse("SELECT * FROM contacts");
assert!(result.is_ok());
let result = result.unwrap();
assert_eq!(result.tables(), vec!["contacts"]);
assert!(matches!(result.protobuf.nodes()[0].0, NodeRef::SelectStmt(_)));
```
` ` ` rust use pg_query :: { Node NodeEnum NodeRef } . let result = pg_query :: parse ( " SELECT * FROM contacts " ) ; assert! ( result . is_ok () ) ; let result = result . unwrap () ; assert_eq! ( result . tables () vec! [ " contacts " ] ) ; assert! ( matches! ( result . protobuf . nodes () [ 0 ] . 0 NodeRef :: SelectStmt ( _ ))) ; ` ` `