This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(prelude_import)] | |
#![no_std] | |
#![feature(plugin, custom_derive, conservative_impl_trait)] | |
#![plugin(rocket_codegen)] | |
#[prelude_import] | |
use std::prelude::v1::*; | |
#[macro_use] | |
extern crate std as std; | |
extern crate rocket; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(prelude_import)] | |
#![no_std] | |
#![feature(plugin, custom_derive)] | |
#![plugin(rocket_codegen)] | |
#[prelude_import] | |
use std::prelude::v1::*; | |
#[macro_use] | |
extern crate std as std; | |
extern crate rocket; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'r` due to conflicting requirements | |
--> tests/lifetimes.rs:37:1 | |
| | |
37 | #[get("/string_state")] | |
| ^^^^^^^^^^^^^^^^^^^^^^^ | |
| | |
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 37:1... | |
--> tests/lifetimes.rs:37:1 | |
| | |
37 | #[get("/string_state")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[macro_use] | |
extern crate serde_derive; | |
extern crate csv; | |
extern crate serde; | |
use serde::{Serialize, Deserialize}; | |
pub trait Record<'de>: Serialize + Deserialize<'de> { | |
fn is_valid(&self) -> Result<(), String>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From https://github.com/Neo-Type/manifest/blob/35bcff0ee504b7a8007bd01cf455554bb4fa51aa/src/main.rs#L56 | |
lazy_static! { | |
// Regular expression to strip invalid file name characters. | |
static ref INVALID_FILE_CHARAS: Regex = Regex::new("[^A-Za-z0-9._-]").unwrap(); | |
} | |
fn main() { | |
// `clap` library is used to parse arguments | |
// The details are not relevant to our discussion | |
let args = make_parser().get_matches(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://github.com/Neo-Type/manifest/blob/35bcff0ee504b7a8007bd01cf455554bb4fa51aa/src/main.rs#L26-L33 | |
/// An "Image" in our manifest | |
#[derive(Serialize, Deserialize, Eq, PartialEq, Clone, Debug)] | |
struct Image<'a> { | |
image: &'a str, | |
repository: &'a str, | |
tag: &'a str, | |
tarball: Cow<'a, str>, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IMAGES="hello-world ubuntu:16.04 alpine:latest busybox:latest" | |
# docker-image is from https://github.com/lawliet89/docker-image | |
docker-image --always-array ${IMAGES} \ | |
| jq '{ utils: [ .[] as $item | $item as { repository: $repo, tag: $tag } | ($repo + ":" + $tag) as $image | $item + { image: $image, tarball: ("images/" + ($image | gsub("[^A-Za-z0-9._-]"; "_")) + ".tar.gz") } ] }' \ | |
>> manifest.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] | |
const _IMPL_DESERIALIZE_FOR_Compact: () = { | |
extern crate serde as _serde; | |
#[automatically_derived] | |
impl<'de, T: CompactPart, H: Serialize + for<'de_inner> Deserialize<'de_inner>> _serde::Deserialize<'de> | |
for Compact<T, H> | |
where T: _serde::Deserialize<'de> | |
{ | |
fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result<Self, __D::Error> | |
where __D: _serde::Deserializer<'de> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! not_err { | |
($e:expr) => (match $e { | |
Ok(e) => e, | |
Err(e) => panic!("{} failed with {:?}", stringify!($e), e), | |
}) | |
} | |
macro_rules! is_err { | |
($e:expr) => (match $e { | |
Ok(e) => panic!("{} did not return with an error, but with {:?}", stringify!($e), e), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate rustc_serialize; | |
use rustc_serialize::base64::{self, ToBase64, FromBase64}; | |
#[derive(Clone, Eq, PartialEq)] | |
pub enum Base64 { | |
Standard(String), | |
UrlSafe(String), | |
Mime(String), | |
} |