Skip to main content

from_slice

Function from_slice 

Source
pub fn from_slice<S>(v: &[u8]) -> Result<S>
where S: Syn,
Available on crate feature json only.
Expand description

Deserialize an instance of Syn type from bytes of JSON text.

This function is equivalent to the following code:

use syn_serde::Syn;

let adapter: <syn::File as Syn>::Adapter = serde_json::from_slice(v)?;
let syn_file = syn::File::from_adapter(&adapter);
Ok(syn_file)