file_name
large_stringlengths
4
69
prefix
large_stringlengths
0
26.7k
suffix
large_stringlengths
0
24.8k
middle
large_stringlengths
0
2.12k
fim_type
large_stringclasses
4 values
tests.rs
use crate::nailgun::{CommandRunner, ARGS_TO_START_NAILGUN, NAILGUN_MAIN_CLASS}; use crate::{PlatformConstraint, Process, ProcessMetadata}; use futures::compat::Future01CompatExt; use hashing::EMPTY_DIGEST; use std::fs::read_link; use std::os::unix::fs::symlink; use std::path::PathBuf; use store::Store; use tempfile::Te...
(base_dir: PathBuf, prefix: Option<String>) -> TempDir { tempfile::Builder::new() .prefix(&(prefix.unwrap_or("".to_string()))) .tempdir_in(&base_dir) .expect("Error making tempdir for local process execution: {:?}") } fn mock_nailgunnable_request(jdk_home: Option<PathBuf>) -> Process { Process { argv:...
unique_temp_dir
identifier_name
tests.rs
use crate::nailgun::{CommandRunner, ARGS_TO_START_NAILGUN, NAILGUN_MAIN_CLASS}; use crate::{PlatformConstraint, Process, ProcessMetadata}; use futures::compat::Future01CompatExt; use hashing::EMPTY_DIGEST; use std::fs::read_link; use std::os::unix::fs::symlink; use std::path::PathBuf; use store::Store; use tempfile::Te...
// Trigger materialization of the nailgun server workdir let materialization_result = materialize_with_jdk(&runner, workdir_for_server, requested_mock_jdk_path.clone()).await; assert!(materialization_result.is_ok()); // Assert that the symlink points to the requested jdk, and not the original one let ma...
{ let workdir_base_tempdir = unique_temp_dir(std::env::temp_dir(), None); let workdir_base = workdir_base_tempdir.path().to_owned(); let runner = mock_nailgun_runner(Some(workdir_base)); let nailgun_name = "mock_server".to_string(); let original_mock_jdk_dir = unique_temp_dir(std::env::temp_dir(), None); ...
identifier_body
tests.rs
use crate::nailgun::{CommandRunner, ARGS_TO_START_NAILGUN, NAILGUN_MAIN_CLASS}; use crate::{PlatformConstraint, Process, ProcessMetadata}; use futures::compat::Future01CompatExt; use hashing::EMPTY_DIGEST; use std::fs::read_link; use std::os::unix::fs::symlink; use std::path::PathBuf; use store::Store; use tempfile::Te...
fn mock_nailgunnable_request(jdk_home: Option<PathBuf>) -> Process { Process { argv: vec![], env: Default::default(), working_directory: None, input_files: EMPTY_DIGEST, output_files: Default::default(), output_directories: Default::default(), timeout: Default::default(), description: ...
.tempdir_in(&base_dir) .expect("Error making tempdir for local process execution: {:?}") }
random_line_split
storage.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. define_error_codes!( "KV:Storage:", TIMEOUT => ("Timeout", "", ""), EMPTY_REQUEST => ("EmptyRequest", "", ""), CLOSED => ("Closed", "", ""), IO => ("Io", "", ""), SCHED_TOO_BUSY => ("SchedTooBusy", "", ""), GC_WORKER_TOO_BU...
UNKNOWN => ("Unknown", "", "") );
COMMIT_TS_EXPIRED => ("CommitTsExpired", "", ""), KEY_VERSION => ("KeyVersion", "",""), PESSIMISTIC_LOCK_NOT_FOUND => ("PessimisticLockNotFound", "", ""), COMMIT_TS_TOO_LARGE => ("CommitTsTooLarge", "", ""),
random_line_split
lib.rs
//! Library to interface MPD // Developers: keep handy: http://www.musicpd.org/doc/protocol/command_reference.html #![deny(missing_docs)] #![deny(warnings)] extern crate bufstream; use std::borrow::Cow; use std::io::{self, BufRead, Write}; use std::net::{TcpStream, ToSocketAddrs}; use bufstream::BufStream; pub mo...
<A>(addr: A) -> io::Result<Connection> where A: ToSocketAddrs { fn new(stream: TcpStream) -> io::Result<Connection> { let mut stream = BufStream::new(stream); let mut buffer = String::new(); try!(stream.read_line(&mut buffer)); if!buffer.starts_with("OK MPD ") { // ...
connect
identifier_name
lib.rs
//! Library to interface MPD // Developers: keep handy: http://www.musicpd.org/doc/protocol/command_reference.html #![deny(missing_docs)] #![deny(warnings)] extern crate bufstream; use std::borrow::Cow; use std::io::{self, BufRead, Write}; use std::net::{TcpStream, ToSocketAddrs}; use bufstream::BufStream; pub mo...
} /// A MPD command pub enum Command<'a> { /// Adds the file `uri` to the playlist (directories are added recursively) Add { /// If `None`, adds the whole database uri: &'a str, }, /// Clears the current playlist Clear, /// Displays the song info of the current song Current...
{ use self::Mode::*; match *self { Consume => "consume", Random => "random", Repeat => "repeat", Single => "single", } }
identifier_body
lib.rs
//! Library to interface MPD // Developers: keep handy: http://www.musicpd.org/doc/protocol/command_reference.html #![deny(missing_docs)] #![deny(warnings)] extern crate bufstream; use std::borrow::Cow; use std::io::{self, BufRead, Write}; use std::net::{TcpStream, ToSocketAddrs}; use bufstream::BufStream; pub mo...
Status => "status", Stop => "stop", Update { uri: None } => "update", Update { uri: Some(uri) } => return format!("update \"{}\"", uri).into(), Volume { level } => return format!("setvol {}", level).into(), }) } } /// A connection to MPD pub stru...
{ return format!("{} {}", mode.str(), if state { "1" } else { "0" }) .into() ...
conditional_block
lib.rs
//! Library to interface MPD // Developers: keep handy: http://www.musicpd.org/doc/protocol/command_reference.html #![deny(missing_docs)] #![deny(warnings)] extern crate bufstream; use std::borrow::Cow; use std::io::{self, BufRead, Write}; use std::net::{TcpStream, ToSocketAddrs}; use bufstream::BufStream; pub mo...
Stop => "stop", Update { uri: None } => "update", Update { uri: Some(uri) } => return format!("update \"{}\"", uri).into(), Volume { level } => return format!("setvol {}", level).into(), }) } } /// A connection to MPD pub struct Connection { buffer: Strin...
Status => "status",
random_line_split
gcp_kms_aead.rs
// Copyright 2020 The Tink-Rust Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
fn encrypt( &self, plaintext: &[u8], additional_data: &[u8], ) -> Result<Vec<u8>, tink_core::TinkError> { let req = EncryptRequest { plaintext: Some(base64::encode_config(plaintext, base64::URL_SAFE)), additional_authenticated_data: Some(base64::encode_con...
} } } impl tink_core::Aead for GcpAead {
random_line_split
gcp_kms_aead.rs
// Copyright 2020 The Tink-Rust Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
{ #[serde(rename = "verifiedAdditionalAuthenticatedDataCrc32c")] pub verified_additional_authenticated_data_crc32c: Option<bool>, #[serde(rename = "verifiedPlaintextCrc32c")] pub verified_plaintext_crc32c: Option<bool>, #[serde(rename = "ciphertextCrc32c")] pub ciphertext_crc32c: Option<String>...
EncryptResponse
identifier_name
gcp_kms_aead.rs
// Copyright 2020 The Tink-Rust Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
} fn decrypt( &self, ciphertext: &[u8], additional_data: &[u8], ) -> Result<Vec<u8>, tink_core::TinkError> { let req = DecryptRequest { ciphertext: Some(base64::encode_config(ciphertext, base64::URL_SAFE)), additional_authenticated_data: Some(base64:...
{ let req = EncryptRequest { plaintext: Some(base64::encode_config(plaintext, base64::URL_SAFE)), additional_authenticated_data: Some(base64::encode_config( additional_data, base64::URL_SAFE, )), ..EncryptRequest::default() ...
identifier_body
ctl_gateway.rs
//! Utilities for generating and reading the self-signed certificate for use with the control //! gateway. use crate::{crypto::keys::NamedRevision, tls::rustls_wrapper::{self, Error as RustlsReadersError}}; use rcgen::{Certificate as RcgenCertificate, Certifica...
(path: impl AsRef<Path>) -> Result<PrivateKey, Error> { let path = get_last_path(path, &format!("{}-*.{}", NAME_PREFIX, KEY_EXTENSION))?; Ok(rustls_wrapper::private_key_from_file(&path)?) } pub fn latest_root_certificate_store(path: impl AsRef<Path>) -> Result<RootCertStore, Error> { let path = get_last_pa...
latest_private_key
identifier_name
ctl_gateway.rs
//! Utilities for generating and reading the self-signed certificate for use with the control //! gateway. use crate::{crypto::keys::NamedRevision, tls::rustls_wrapper::{self, Error as RustlsReadersError}}; use rcgen::{Certificate as RcgenCertificate,
use rustls::{Certificate, PrivateKey, RootCertStore}; use std::{fs::{self, File}, io::{Error as IoError, Write}, path::{Path, PathBuf}}; use thiserror::Error; use webpki::DnsNameRef; const NAME_PREFIX: &str = "ctl-gateway"; co...
CertificateParams, DistinguishedName, DnType, RcgenError, PKCS_ECDSA_P256_SHA256};
random_line_split
ctl_gateway.rs
//! Utilities for generating and reading the self-signed certificate for use with the control //! gateway. use crate::{crypto::keys::NamedRevision, tls::rustls_wrapper::{self, Error as RustlsReadersError}}; use rcgen::{Certificate as RcgenCertificate, Certifica...
pub fn latest_certificates(path: impl AsRef<Path>) -> Result<Vec<Certificate>, Error> { let path = get_last_path(path, &format!("{}-*.{}", NAME_PREFIX, CRT_EXTENSION))?; Ok(rustls_wrapper::certificates_from_file(&path)?) } pub fn latest_private_key(path: impl AsRef<Path>) -> Result<PrivateKey, Error> { l...
{ let pattern = search_directory.as_ref().join(file_pattern); let pattern = pattern.to_string_lossy(); glob::glob(&pattern).expect("valid pattern") .filter_map(std::result::Result::ok) .filter(|p| p.metadata().map(|m| m.is_file()).unwrap_or(false)) ...
identifier_body
content_type.rs
use std::{ error::Error as StdError, fmt::{self, Display}, str::FromStr, }; use mime::Mime; use super::{Header, HeaderName}; use crate::BoxError; /// `Content-Type` of the body
/// /// [mime type]: https://www.iana.org/assignments/media-types/media-types.xhtml #[derive(Debug, Clone, PartialEq, Eq)] pub struct ContentType(Mime); impl ContentType { /// A `ContentType` of type `text/plain; charset=utf-8` /// /// Indicates that the body is in utf-8 encoded plain text. pub const T...
/// /// This struct can represent any valid [mime type], which can be parsed via /// [`ContentType::parse`]. Constants are provided for the most-used mime-types. /// /// Defined in [RFC2045](https://tools.ietf.org/html/rfc2045#section-5)
random_line_split
content_type.rs
use std::{ error::Error as StdError, fmt::{self, Display}, str::FromStr, }; use mime::Mime; use super::{Header, HeaderName}; use crate::BoxError; /// `Content-Type` of the body /// /// This struct can represent any valid [mime type], which can be parsed via /// [`ContentType::parse`]. Constants are provi...
<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de>, { struct ContentTypeVisitor; impl<'de> Visitor<'de> for ContentTypeVisitor { type Value = ContentType; // The error message which states what the Visitor expec...
deserialize
identifier_name
yield.rs
// -*- rust -*- // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // ...
task::yield(); error!("2"); task::yield(); error!("3"); result.unwrap().recv(); } fn child() { error!("4"); task::yield(); error!("5"); task::yield(); error!("6"); }
builder.future_result(|r| { result = Some(r); }); builder.spawn(child); error!("1");
random_line_split
yield.rs
// -*- rust -*- // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // ...
() { error!("4"); task::yield(); error!("5"); task::yield(); error!("6"); }
child
identifier_name
yield.rs
// -*- rust -*- // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // ...
fn child() { error!("4"); task::yield(); error!("5"); task::yield(); error!("6"); }
{ let mut result = None; let mut builder = task::task(); builder.future_result(|r| { result = Some(r); }); builder.spawn(child); error!("1"); task::yield(); error!("2"); task::yield(); error!("3"); result.unwrap().recv(); }
identifier_body
device.rs
use std::collections::HashMap; use std::fmt; use std::result::Result; use super::action::Action; use super::attribute::Attribute; use super::error::DeviceError; pub enum Member { Attribute(Box<dyn Attribute>), Action(Box<dyn Action>), } impl fmt::Debug for Member { fn fmt(&self, fmt: &mut fmt::Formatter)...
}
{ self.members.iter() }
identifier_body
device.rs
use std::collections::HashMap; use std::fmt; use std::result::Result; use super::action::Action; use super::attribute::Attribute; use super::error::DeviceError; pub enum Member { Attribute(Box<dyn Attribute>), Action(Box<dyn Action>), } impl fmt::Debug for Member { fn fmt(&self, fmt: &mut fmt::Formatter)...
} pub fn iter(&self) -> std::collections::hash_map::Iter<String, Member> { self.members.iter() } }
{ Err(DeviceError::PathNotFound(path)) }
conditional_block
device.rs
use std::collections::HashMap; use std::fmt; use std::result::Result; use super::action::Action; use super::attribute::Attribute; use super::error::DeviceError; pub enum Member { Attribute(Box<dyn Attribute>), Action(Box<dyn Action>), } impl fmt::Debug for Member { fn fmt(&self, fmt: &mut fmt::Formatter)...
(&self, path: &str) -> Option<&Member> { self.members.get(path) } pub fn insert(&mut self, path: &str, member: Member) -> Result<(), DeviceError> { let path = String::from(path); if self.members.contains_key(&path) { Err(DeviceError::PathExists(path)) } else { ...
get
identifier_name
device.rs
use std::collections::HashMap; use std::fmt; use std::result::Result; use super::action::Action; use super::attribute::Attribute; use super::error::DeviceError; pub enum Member { Attribute(Box<dyn Attribute>), Action(Box<dyn Action>), } impl fmt::Debug for Member { fn fmt(&self, fmt: &mut fmt::Formatter)...
Member::Action(action) => fmt.debug_tuple("Action").field(action).finish(), } } } #[derive(Debug)] pub struct Device { members: HashMap<String, Member>, } impl Device { pub fn new() -> Device { Device { members: HashMap::new(), } } pub fn get(&self,...
random_line_split
uniq.rs
#![crate_name = "uu_uniq"] /* * This file is part of the uutils coreutils package. * * (c) Chirag B Jadwani <chirag.jadwani@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * */ extern crate getopts; #[macro_use] extern ...
pub fn uumain(args: Vec<String>) -> i32 { let mut opts = Options::new(); opts.optflag("c", "count", "prefix lines by the number of occurrences"); opts.optflag("d", "repeated", "only print duplicate lines"); opts.optflagopt( "D", "all-repeated", "print all duplicate lines delim...
{ matches.opt_str(opt_name).map(|arg_str| { let opt_val: Option<T> = arg_str.parse().ok(); opt_val.unwrap_or_else(|| crash!(1, "Invalid argument for {}: {}", opt_name, arg_str)) }) }
identifier_body
uniq.rs
#![crate_name = "uu_uniq"] /* * This file is part of the uutils coreutils package. * * (c) Chirag B Jadwani <chirag.jadwani@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * */ extern crate getopts; #[macro_use] extern ...
uniques_only: bool, all_repeated: bool, delimiters: String, show_counts: bool, skip_fields: Option<usize>, slice_start: Option<usize>, slice_stop: Option<usize>, ignore_case: bool, zero_terminated: bool, } impl Uniq { pub fn print_uniq<R: Read, W: Write>(&self, reader: &mut BufR...
static NAME: &'static str = "uniq"; static VERSION: &'static str = env!("CARGO_PKG_VERSION"); struct Uniq { repeats_only: bool,
random_line_split
uniq.rs
#![crate_name = "uu_uniq"] /* * This file is part of the uutils coreutils package. * * (c) Chirag B Jadwani <chirag.jadwani@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * */ extern crate getopts; #[macro_use] extern ...
<W: Write>(&self, writer: &mut BufWriter<W>, line: &str, count: usize, print_delimiter: bool) { let line_terminator = self.get_line_terminator(); if print_delimiter { crash_if_err!(1, writer.write_all(&[line_terminator])); } crash_if_err!(1, if self.show_counts { ...
print_line
identifier_name
uniq.rs
#![crate_name = "uu_uniq"] /* * This file is part of the uutils coreutils package. * * (c) Chirag B Jadwani <chirag.jadwani@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * */ extern crate getopts; #[macro_use] extern ...
first_line_printed } fn print_line<W: Write>(&self, writer: &mut BufWriter<W>, line: &str, count: usize, print_delimiter: bool) { let line_terminator = self.get_line_terminator(); if print_delimiter { crash_if_err!(1, writer.write_all(&[line_terminator])); } ...
{ for line in lines[1..].iter() { self.print_line(writer, line, count, print_delimiter && !first_line_printed); first_line_printed = true; count += 1; } }
conditional_block
object-lifetime-default.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { }
#[rustc_object_lifetime_default] struct G<'a,'b,T:'a,U:'a+'b>(&'a T, &'b U); //~ ERROR 'a,Ambiguous
random_line_split
object-lifetime-default.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ }
identifier_body
object-lifetime-default.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<T>(T); //~ ERROR BaseDefault #[rustc_object_lifetime_default] struct B<'a,T>(&'a (), T); //~ ERROR BaseDefault #[rustc_object_lifetime_default] struct C<'a,T:'a>(&'a T); //~ ERROR 'a #[rustc_object_lifetime_default] struct D<'a,'b,T:'a+'b>(&'a T, &'b T); //~ ERROR Ambiguous #[rustc_object_lifetime_default] struct ...
A
identifier_name
issue-28934.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let x = 0u8; Parser(&x, &x).parse_nested_block(|input| input.expect_exhausted()).unwrap(); }
random_line_split
issue-28934.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn expect_exhausted(&mut self) -> Result<(), ()> { Ok(()) } } fn main() { let x = 0u8; Parser(&x, &x).parse_nested_block(|input| input.expect_exhausted()).unwrap(); }
{ panic!() }
identifier_body
issue-28934.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<F, T>(&mut self, parse: F) -> Result<T, ()> where for<'tt> F: FnOnce(&mut Parser<'i, 'tt>) -> T { panic!() } fn expect_exhausted(&mut self) -> Result<(), ()> { Ok(()) } } fn main() { let x = 0u8; Parser(&x, &x).parse_nested_block(|input| input.expect_exhausted()).unwra...
parse_nested_block
identifier_name
ref-struct-async.rs
// edition:2018 #![allow(non_snake_case)] use std::pin::Pin; struct Struct { } impl Struct { // Test using `&Struct` explicitly: async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { f //~ ERROR lifetime mismatch }
async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { f //~ ERROR lifetime mismatch } async fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 { f //~ ERROR lifetime mismatch } async fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 { f //~ ...
async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { f //~ ERROR lifetime mismatch }
random_line_split
ref-struct-async.rs
// edition:2018 #![allow(non_snake_case)] use std::pin::Pin; struct Struct { } impl Struct { // Test using `&Struct` explicitly: async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { f //~ ERROR lifetime mismatch } async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { f //...
{ }
identifier_body
ref-struct-async.rs
// edition:2018 #![allow(non_snake_case)] use std::pin::Pin; struct
{ } impl Struct { // Test using `&Struct` explicitly: async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { f //~ ERROR lifetime mismatch } async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { f //~ ERROR lifetime mismatch } async fn pin_ref_Struct(self: Pin<&Struc...
Struct
identifier_name
main.rs
#![feature(conservative_impl_trait)] #[macro_use] extern crate clap; #[macro_use] extern crate itertools; extern crate rustyline; extern crate siphasher; extern crate lalrpop_util; #[macro_use] mod native; mod cli; mod grammar; mod value; mod interpreter; mod repl; mod scope; mod string_interner; use std::io::Read;...
repl::Repl::start(); } }
result = interpreter.evaluate(x); } println!("=> {}", result.to_string(&interpreter.interner)) } else {
random_line_split
main.rs
#![feature(conservative_impl_trait)] #[macro_use] extern crate clap; #[macro_use] extern crate itertools; extern crate rustyline; extern crate siphasher; extern crate lalrpop_util; #[macro_use] mod native; mod cli; mod grammar; mod value; mod interpreter; mod repl; mod scope; mod string_interner; use std::io::Read;...
else { repl::Repl::start(); } }
{ let mut input = String::new(); file.read_to_string(&mut input).expect("Couldn't read file"); let mut interpreter = interpreter::Interpreter::new(); let parsed = grammar::parse(&input, &mut interpreter.interner).unwrap(); let mut result = Value::empty_list(); for x in &...
conditional_block
main.rs
#![feature(conservative_impl_trait)] #[macro_use] extern crate clap; #[macro_use] extern crate itertools; extern crate rustyline; extern crate siphasher; extern crate lalrpop_util; #[macro_use] mod native; mod cli; mod grammar; mod value; mod interpreter; mod repl; mod scope; mod string_interner; use std::io::Read;...
{ if let Some(mut file) = cli::get_args() { let mut input = String::new(); file.read_to_string(&mut input).expect("Couldn't read file"); let mut interpreter = interpreter::Interpreter::new(); let parsed = grammar::parse(&input, &mut interpreter.interner).unwrap(); let mut re...
identifier_body
main.rs
#![feature(conservative_impl_trait)] #[macro_use] extern crate clap; #[macro_use] extern crate itertools; extern crate rustyline; extern crate siphasher; extern crate lalrpop_util; #[macro_use] mod native; mod cli; mod grammar; mod value; mod interpreter; mod repl; mod scope; mod string_interner; use std::io::Read;...
() { if let Some(mut file) = cli::get_args() { let mut input = String::new(); file.read_to_string(&mut input).expect("Couldn't read file"); let mut interpreter = interpreter::Interpreter::new(); let parsed = grammar::parse(&input, &mut interpreter.interner).unwrap(); let mut...
main
identifier_name
template.rs
use syntax::parse::token; use syntax::parse::parser::Parser; use syntax::ext::base; use parse_utils::block_to_string; use parse_utils::is_tag_start; use parse::rust::parse_rust_tag; use parse::include::parse_include_tag; use parse::print::parse_print_tag; use tags::TEMPLATE; use tags::RUST; use tags::PRINT; use tags...
( parser: &mut Parser, context: &base::ExtCtxt ) -> Vec<SubTag> { let mut sub_tags = Vec::new(); // to know when we have a piece of HTML to display as it let mut start_html_block = parser.span.clone(); while parser.token!= token::EOF { // TODO handle <%= (%= is interpreted as one tok...
parse_inner_template
identifier_name
template.rs
use syntax::parse::token; use syntax::parse::parser::Parser; use syntax::ext::base; use parse_utils::block_to_string; use parse_utils::is_tag_start; use parse::rust::parse_rust_tag; use parse::include::parse_include_tag; use parse::print::parse_print_tag; use tags::TEMPLATE; use tags::RUST; use tags::PRINT; use tags...
// to know when we have a piece of HTML to display as it let mut start_html_block = parser.span.clone(); while parser.token!= token::EOF { // TODO handle <%= (%= is interpreted as one token) if!is_tag_start(parser) { parser.bump(); continue; } // the...
random_line_split
template.rs
use syntax::parse::token; use syntax::parse::parser::Parser; use syntax::ext::base; use parse_utils::block_to_string; use parse_utils::is_tag_start; use parse::rust::parse_rust_tag; use parse::include::parse_include_tag; use parse::print::parse_print_tag; use tags::TEMPLATE; use tags::RUST; use tags::PRINT; use tags...
parser.fatal(format!( "Expected `<% template xxx() %>`, found <% template {} {} {}{}", one, two, three, four ).as_slice()); } }; } /// /// /// fn parse_end_template(parser: &mut Parser) { match ( ...
{ match ( parser.parse_ident(), parser.parse_fn_decl(true), parser.bump_and_get(), parser.bump_and_get() ) { ( functioname, ref function_decl, token::BINOP(token::PERCENT), token::GT ) => { state.name = ...
identifier_body
js.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Smart pointers for the JS-managed DOM objects. //! //! The DOM is made up of DOM objects whose lifetime is ent...
(initial: T) -> MutHeap<T> { MutHeap { val: Cell::new(initial), } } /// Set this `MutHeap` to the given value, calling write barriers as /// appropriate. pub fn set(&self, val: T) { self.val.set(val) } /// Set the value in this `MutHeap`, calling read barrie...
new
identifier_name
js.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Smart pointers for the JS-managed DOM objects. //! //! The DOM is made up of DOM objects whose lifetime is ent...
, } } /// Retrieve a copy of the inner optional `JS<T>` as `LayoutJS<T>`. /// For use by layout, which can't use safe types like Temporary. pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutJS<T>> { self.ptr.get().map(|js| js.to_layout()) } } impl<T: HeapGCValue+Copy> Defaul...
{ let inner = cb(); self.set(Some(JS::from_rooted(inner.clone()))); inner }
conditional_block
js.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Smart pointers for the JS-managed DOM objects. //! //! The DOM is made up of DOM objects whose lifetime is ent...
pub unsafe fn from_raw(raw: *const T) -> Unrooted<T> { assert!(!raw.is_null()); Unrooted { ptr: NonZero::new(raw) } } /// Create a new unrooted value from a `JS<T>`. #[allow(unrooted_must_root)] pub fn from_js(ptr: JS<T>) -> Unrooted<T> { Unrooted { ...
} impl<T: Reflectable> Unrooted<T> { /// Create a new JS-owned value wrapped from a raw Rust pointer.
random_line_split
js.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Smart pointers for the JS-managed DOM objects. //! //! The DOM is made up of DOM objects whose lifetime is ent...
} impl<T: Reflectable> Temporary<T> { /// Create a new `Temporary` value from an unrooted value. #[allow(unrooted_must_root)] pub fn from_unrooted(unrooted: Unrooted<T>) -> Temporary<T> { Temporary { inner: JS { ptr: unrooted.ptr }, _js_ptr: unrooted.reflector().get_jsobjec...
{ self.inner == other.inner }
identifier_body
enum_messages.rs
use proc_macro2::TokenStream; use quote::quote; use syn::{Data, DeriveInput}; use crate::helpers::{non_enum_error, HasStrumVariantProperties, HasTypeProperties}; pub fn
(ast: &DeriveInput) -> syn::Result<TokenStream> { let name = &ast.ident; let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl(); let variants = match &ast.data { Data::Enum(v) => &v.variants, _ => return Err(non_enum_error()), }; let type_properties = ast.get...
enum_message_inner
identifier_name
enum_messages.rs
use proc_macro2::TokenStream; use quote::quote; use syn::{Data, DeriveInput}; use crate::helpers::{non_enum_error, HasStrumVariantProperties, HasTypeProperties}; pub fn enum_message_inner(ast: &DeriveInput) -> syn::Result<TokenStream> { let name = &ast.ident; let (impl_generics, ty_generics, where_clause) = a...
if let Some(msg) = detailed_messages { let params = params.clone(); // Push the simple message. detailed_arms .push(quote! { &#name::#ident #params => ::core::option::Option::Some(#msg) }); } } if arms.len() < variants.len() { arms.pu...
{ let params = params.clone(); // Push the simple message. let tokens = quote! { &#name::#ident #params => ::core::option::Option::Some(#msg) }; arms.push(tokens.clone()); if detailed_messages.is_none() { detailed_arms.push(tokens); ...
conditional_block
enum_messages.rs
use proc_macro2::TokenStream; use quote::quote; use syn::{Data, DeriveInput}; use crate::helpers::{non_enum_error, HasStrumVariantProperties, HasTypeProperties}; pub fn enum_message_inner(ast: &DeriveInput) -> syn::Result<TokenStream>
use syn::Fields::*; let params = match variant.fields { Unit => quote! {}, Unnamed(..) => quote! { (..) }, Named(..) => quote! { {..} }, }; // You can't disable getting the serializations. { let serialization_variants = ...
{ let name = &ast.ident; let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl(); let variants = match &ast.data { Data::Enum(v) => &v.variants, _ => return Err(non_enum_error()), }; let type_properties = ast.get_type_properties()?; let strum_module_path =...
identifier_body
enum_messages.rs
use proc_macro2::TokenStream; use quote::quote; use syn::{Data, DeriveInput}; use crate::helpers::{non_enum_error, HasStrumVariantProperties, HasTypeProperties}; pub fn enum_message_inner(ast: &DeriveInput) -> syn::Result<TokenStream> { let name = &ast.ident;
let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl(); let variants = match &ast.data { Data::Enum(v) => &v.variants, _ => return Err(non_enum_error()), }; let type_properties = ast.get_type_properties()?; let strum_module_path = type_properties.crate_module...
random_line_split
lib.rs
//! Isbfc is an optimizing brainfuck compiler targeting x86_64 Linux //! //! # Examples //! ``` //! extern crate isbfc; //! //! fn main() { //! // 2048 is the tape length to use //! let assembly = isbfc::parse(",[.,]").unwrap().optimize().compile(2048); //! print!("{}", assembly); //! } //! ``` use std::fm...
} fn ast_to_tokens(ast: Vec<AST>) -> Vec<Token> { let mut tokens = Vec::new(); for i in ast { match i { AST::Output => { tokens.push(Token::LoadOut(0, 0)); tokens.push(Token::Output); }, AST::Input => tokens.push(Token::Input), ...
{ self.tokens.fmt(f) }
identifier_body
lib.rs
//! Isbfc is an optimizing brainfuck compiler targeting x86_64 Linux //! //! # Examples //! ``` //! extern crate isbfc; //! //! fn main() { //! // 2048 is the tape length to use //! let assembly = isbfc::parse(",[.,]").unwrap().optimize().compile(2048); //! print!("{}", assembly); //! } //! ``` use std::fm...
(ast: Vec<AST>) -> Self { IsbfcIR { tokens: ast_to_tokens(ast) } } }
from_ast
identifier_name
lib.rs
//! Isbfc is an optimizing brainfuck compiler targeting x86_64 Linux //! //! # Examples //! ``` //! extern crate isbfc; //! //! fn main() { //! // 2048 is the tape length to use //! let assembly = isbfc::parse(",[.,]").unwrap().optimize().compile(2048); //! print!("{}", assembly); //! } //! ``` use std::fm...
impl IsbfcIR { pub fn from_ast(ast: Vec<AST>) -> Self { IsbfcIR { tokens: ast_to_tokens(ast) } } }
}
random_line_split
issue-10902.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{}
identifier_body
issue-10902.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} } pub mod two_fields { pub trait T { fn dummy(&self) { } } pub struct P<'a> { car: &'a (T + 'a), cdr: &'a (T + 'a) } pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { P{ car: car, cdr: cdr } } } fn main() {}
pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { P(car, cdr)
random_line_split
issue-10902.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'a> { car: &'a (T + 'a), cdr: &'a (T + 'a) } pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { P{ car: car, cdr: cdr } } } fn main() {}
P
identifier_name
htmltimeelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLTimeElementBinding; use dom::bindings::js::Root; use dom::bindings::str:...
}
{ let element = HTMLTimeElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLTimeElementBinding::Wrap) }
identifier_body
htmltimeelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLTimeElementBinding; use dom::bindings::js::Root; use dom::bindings::str:...
} }
Node::reflect_node(box element, document, HTMLTimeElementBinding::Wrap)
random_line_split
htmltimeelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLTimeElementBinding; use dom::bindings::js::Root; use dom::bindings::str:...
(localName: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLTimeElement { HTMLTimeElement { htmlelement: HTMLElement::new_inherited(localName, prefix, document) } } #[allow(unrooted_must_root)] pub fn new(localName: Atom, prefix: Option<DOMString>, ...
new_inherited
identifier_name
misc.rs
use num::Num; use signed::Signed; use create::clone; use length::normalize; use trig::Trig; pub use vec4::inverse; pub use vec4::lerp; pub use vec4::min; pub use vec4::max; pub use vec4::clamp; pub use vec4::eq; pub use vec4::ne; #[inline] pub fn conjugate<'a, 'b, T: Copy + Signed>(out: &'a mut [T; 4], a: &'b [T; 4...
() { let mut v = [0, 0, 0, 0]; conjugate(&mut v, &[1, 1, 1, 1]); assert!(v[0] == -1); assert!(v[1] == -1); assert!(v[2] == -1); assert!(v[3] == 1); } #[inline] pub fn calculate_w<'a, 'b, T: Copy + Signed>(out: &'a mut [T; 4], a: &'b [T; 4]) -> &'a mut [T; 4] { out[0] = a[0]; out[1] = a[...
test_conjugate
identifier_name
misc.rs
use num::Num; use signed::Signed; use create::clone; use length::normalize; use trig::Trig; pub use vec4::inverse; pub use vec4::lerp; pub use vec4::min; pub use vec4::max; pub use vec4::clamp; pub use vec4::eq; pub use vec4::ne; #[inline] pub fn conjugate<'a, 'b, T: Copy + Signed>(out: &'a mut [T; 4], a: &'b [T; 4...
let ax = a[0].to_f64(); let ay = a[1].to_f64(); let az = a[2].to_f64(); let aw = a[3].to_f64(); let mut bx = b[0].to_f64(); let mut by = b[1].to_f64(); let mut bz = b[2].to_f64(); let mut bw = b[3].to_f64(); let mut cosom = ax * bx + ay * by + az * bz + aw * bw; let mut sinom; ...
} #[inline] pub fn slerp<'a, 'b, T: Copy + Signed, N: Copy + Signed>(out: &'a mut [T; 4], a: &'b [T; 4], b: &'b [T; 4], t: N) -> &'a mut [T; 4] { let t_f64 = t.to_f64();
random_line_split
misc.rs
use num::Num; use signed::Signed; use create::clone; use length::normalize; use trig::Trig; pub use vec4::inverse; pub use vec4::lerp; pub use vec4::min; pub use vec4::max; pub use vec4::clamp; pub use vec4::eq; pub use vec4::ne; #[inline] pub fn conjugate<'a, 'b, T: Copy + Signed>(out: &'a mut [T; 4], a: &'b [T; 4...
else { scale0 = 1_f64 - t_f64; scale1 = t_f64; } out[0] = T::from_f64(scale0 * ax + scale1 * bx); out[1] = T::from_f64(scale0 * ay + scale1 * by); out[2] = T::from_f64(scale0 * az + scale1 * bz); out[3] = T::from_f64(scale0 * aw + scale1 * bw); out }
{ omega = cosom.acos(); sinom = omega.sin(); sinom = if sinom != 0_f64 {1_f64 / sinom} else {sinom}; scale0 = ((1_f64 - t_f64) * omega).sin() * sinom; scale1 = (t_f64 * omega).sin() * sinom; }
conditional_block
misc.rs
use num::Num; use signed::Signed; use create::clone; use length::normalize; use trig::Trig; pub use vec4::inverse; pub use vec4::lerp; pub use vec4::min; pub use vec4::max; pub use vec4::clamp; pub use vec4::eq; pub use vec4::ne; #[inline] pub fn conjugate<'a, 'b, T: Copy + Signed>(out: &'a mut [T; 4], a: &'b [T; 4...
#[inline] pub fn nlerp<'a, 'b, T: Copy + Num, N: Copy + Num>(out: &'a mut [T; 4], a: &'b [T; 4], b: &'b [T; 4], t: N) -> &'a mut [T; 4] { let tmp = clone(lerp(out, a, b, t)); normalize(out, &tmp) } #[inline] pub fn slerp<'a, 'b, T: Copy + Signed, N: Copy + Signed>(out: &'a mut [T; 4], a: &'b [T; 4], b: &'b [...
{ out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = (T::one() - a[0] * a[0] - a[1] * a[1] - a[2] * a[2]).abs().sqrt(); out }
identifier_body
binops.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}
random_line_split
binops.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { assert!((!(true < false))); assert!((!(true <= false))); assert!((true > false)); assert!((true >= false)); assert!((false < true)); assert!((false <= true)); assert!((!(false > true))); assert!((!(false >= true))); // Bools support bitwise binops assert_eq!(false & false,...
test_bool
identifier_name
binops.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { test_nil(); test_bool(); test_ptr(); test_class(); }
{ let q = p(1, 2); let mut r = p(1, 2); unsafe { println!("q = {:x}, r = {:x}", (::std::mem::transmute::<*const p, uint>(&q)), (::std::mem::transmute::<*const p, uint>(&r))); } assert_eq!(q, r); r.y = 17; assert!((r.y != q.y)); assert_eq!(r.y, 17); assert!((q != r)); }
identifier_body
collatz.rs
pub struct
{ curr: u64, done: bool, } impl Collatz { pub fn new(start: u64) -> Collatz { Collatz { curr: start, done: false, } } } impl Iterator for Collatz { type Item = u64; fn next(&mut self) -> Option<u64> { if self.done { return None }; let ...
Collatz
identifier_name
collatz.rs
pub struct Collatz { curr: u64, done: bool, } impl Collatz { pub fn new(start: u64) -> Collatz { Collatz { curr: start, done: false, } } } impl Iterator for Collatz { type Item = u64; fn next(&mut self) -> Option<u64> { if self.done { return No...
, }; result } } #[test] fn test_collatz() { let v = [10, 5, 16, 8, 4, 2, 1]; let mut c = Collatz::new(10); for i in 0..7 { assert_eq!(c.next(), Some(v[i])); } assert_eq!(c.next(), None); }
{ n * 3 + 1 }
conditional_block
collatz.rs
pub struct Collatz { curr: u64, done: bool, } impl Collatz { pub fn new(start: u64) -> Collatz { Collatz {
} } } impl Iterator for Collatz { type Item = u64; fn next(&mut self) -> Option<u64> { if self.done { return None }; let result = Some(self.curr); self.curr = match self.curr { n if n <= 1 => { self.done = true; 1 }, n if n % 2 == 0 => { n / 2 }, ...
curr: start, done: false,
random_line_split
source.rs
use check_file; use ffprobe; use path; use std::cmp::Ordering; use std::error::Error as StdError; use std::fmt; use std::io; use std::iter::IntoIterator; use std::ops::{Deref, DerefMut}; use std::path::PathBuf; #[derive(Debug)] pub enum Error { CheckFileError(check_file::Error), FFProbeError { path: Pa...
(&self) -> Option<&StdError> { match *self { Error::CheckFileError(ref error) => Some(error), Error::FFProbeError { ref error,.. } => Some(error), Error::PathError { ref error,.. } => Some(error), Error::SourceDirectory { ref error,.. } => Some(error), ...
cause
identifier_name
source.rs
use check_file; use ffprobe; use path; use std::cmp::Ordering; use std::error::Error as StdError; use std::fmt; use std::io; use std::iter::IntoIterator; use std::ops::{Deref, DerefMut}; use std::path::PathBuf; #[derive(Debug)] pub enum Error { CheckFileError(check_file::Error), FFProbeError { path: Pa...
fn ffprobe_it(path: &PathBuf) -> SourceResult<Option<ffprobe::FFProbe>> { use self::Error::FFProbeError; let res = ffprobe::ffprobe(path); match res { Err(e) => { Err(FFProbeError { path: path.to_owned(), error: e, }) } Ok(r)...
{ use path::{RecursivePathIterator, PathType}; let paths: Vec<PathBuf> = match path.is_dir() { false => vec![path], true => { RecursivePathIterator::new(path) .filter_map(|x| { match x { PathType::Directory(_) => None, ...
identifier_body
source.rs
use check_file; use ffprobe; use path; use std::cmp::Ordering; use std::error::Error as StdError; use std::fmt; use std::io; use std::iter::IntoIterator; use std::ops::{Deref, DerefMut}; use std::path::PathBuf; #[derive(Debug)] pub enum Error { CheckFileError(check_file::Error), FFProbeError { path: Pa...
let mut expanded_paths: Vec<PathBuf> = paths.into_iter() .flat_map(expand_path) .collect(); expanded_paths.sort(); expanded_paths.dedup(); // Quick filtering using 'file' let (paths, skipped_file) = try!(check_file::check_files(expanded_paths.into_iter()...
{ return Err(Error::StraySource { path: path.clone() }); }
conditional_block
source.rs
use check_file; use ffprobe; use path; use std::cmp::Ordering; use std::error::Error as StdError; use std::fmt; use std::io; use std::iter::IntoIterator; use std::ops::{Deref, DerefMut}; use std::path::PathBuf; #[derive(Debug)] pub enum Error { CheckFileError(check_file::Error), FFProbeError { path: Pa...
.collect(); let paths = try!(paths); if let Some(path) = paths.iter().filter(|&path|!path.starts_with(&base_directory)).next() { return Err(Error::StraySource { path: path.clone() }); } let mut expanded_paths: Vec<PathBuf> = paths.into_iter() .flat_ma...
let paths: Result<Vec<_>, Error> = paths.into_iter() .map(|x| x.into()) .map(canonicalize)
random_line_split
fn-simple.rs
// rustfmt-normalize_comments: true fn simple(/*pre-comment on a function!?*/ i: i32/*yes, it's possible! */ ,response: NoWay /* hose */) { fn op(x: Typ, key : &[u8], upd : Box<Fn(Option<&memcache::Item>) -> (memcache::Status, Result<memcache::Item, Option<String>>)>) -> MapR...
fn zzzzzzzzzzzzzzzzzzzz<Type, NodeType> (selff: Type, mut handle: node::Handle<IdRef<'id, Node<K, V>>, Type, NodeType>) -> SearchStack<'a, K, V, Type, NodeType>{ } unsafe fn generic_call(cx: *mut JSContext, argc: libc::c_uint, vp: *mut JSVal, is_lenient: bool, ...
{}
identifier_body
fn-simple.rs
// rustfmt-normalize_comments: true fn simple(/*pre-comment on a function!?*/ i: i32/*yes, it's possible! */ ,response: NoWay /* hose */) { fn op(x: Typ, key : &[u8], upd : Box<Fn(Option<&memcache::Item>) -> (memcache::Status, Result<memcache::Item, Option<String>>)>) -> MapR...
(listener:Box< AsyncCORSResponseListener+Send >, script_chan: Box<ScriptChan+Send>) { } fn some_func<T:Box<Trait+Bound>>(val:T){} fn zzzzzzzzzzzzzzzzzzzz<Type, NodeType> (selff: Type, mut handle: node::Handle<IdRef<'id, Node<K, V>>, Type, NodeType>) -> SearchStack<'a, ...
http_fetch_async
identifier_name
fn-simple.rs
// rustfmt-normalize_comments: true fn simple(/*pre-comment on a function!?*/ i: i32/*yes, it's possible! */ ,response: NoWay /* hose */) { fn op(x: Typ, key : &[u8], upd : Box<Fn(Option<&memcache::Item>) -> (memcache::Status, Result<memcache::Item, Option<String>>)>) -> MapR...
where T: Fn(// First arg A, // Second argument B, C, D, /* pre comment */ E /* last comment */) -> &SomeType { arg(a, b, c, d, e) } fn foo() -> ! {} pub fn http_fetch_async(listener:Box< AsyncCORSResponseListener+Send >, script_chan: Box<ScriptChan+Send>) { } fn some_func<T:Box<Tr...
simple(/* does this preserve comments now? */ 42, NoWay) } fn generic<T>(arg: T) -> &SomeType
random_line_split
lib.rs
#![feature(core)] #![cfg_attr(test, feature(test))] use std::mem; use std::ops::Deref; mod raycast; mod voxel_bounds; pub use voxel_bounds::VoxelBounds; #[derive(Debug)] pub struct VoxelTree<T> { /// The log_2 of the tree's size. lg_size: u8, /// Force the top level to always be branches; /// it saves a bra...
#[test] fn wrong_voxel_size_is_not_found() { let mut tree: VoxelTree<i32> = VoxelTree::new(); *tree.get_mut_or_create(VoxelBounds::new(4, 4, -4, 1)) = TreeBody::Leaf(1); assert_eq!(tree.get(VoxelBounds::new(4, 4, -4, 0)), None); assert_eq!(tree.get(VoxelBounds::new(4, 4, -4, 2)), None); } #[t...
{ let mut tree: VoxelTree<i32> = VoxelTree::new(); *tree.get_mut_or_create(VoxelBounds::new(1, 1, 1, 0)) = TreeBody::Leaf(1); *tree.get_mut_or_create(VoxelBounds::new(8, -8, 4, 0)) = TreeBody::Leaf(2); *tree.get_mut_or_create(VoxelBounds::new(2, 0, 4, 4)) = TreeBody::Leaf(3); *tree.get_mut_or_create...
identifier_body
lib.rs
use std::mem; use std::ops::Deref; mod raycast; mod voxel_bounds; pub use voxel_bounds::VoxelBounds; #[derive(Debug)] pub struct VoxelTree<T> { /// The log_2 of the tree's size. lg_size: u8, /// Force the top level to always be branches; /// it saves a branch in the grow logic. contents: Branches<T>, } #[...
#![feature(core)] #![cfg_attr(test, feature(test))]
random_line_split
lib.rs
#![feature(core)] #![cfg_attr(test, feature(test))] use std::mem; use std::ops::Deref; mod raycast; mod voxel_bounds; pub use voxel_bounds::VoxelBounds; #[derive(Debug)] pub struct VoxelTree<T> { /// The log_2 of the tree's size. lg_size: u8, /// Force the top level to always be branches; /// it saves a bra...
(&self, voxel: VoxelBounds) -> i32 { // When we compare the voxel position to octree bounds to choose subtrees // for insertion, we'll be comparing voxel position to values of 2^n and // -2^n, so we can just use the position bits to branch directly. // This actually works for negative values too, withou...
find_mask
identifier_name
console.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::ConsoleBinding; use dom::bindings::codegen::Bindings::ConsoleBinding::Consol...
(global: GlobalRef) -> Console { Console { reflector_: Reflector::new(), global: GlobalField::from_rooted(&global), } } pub fn new(global: GlobalRef) -> Root<Console> { reflect_dom_object(box Console::new_inherited(global), global, ConsoleBinding::Wrap) } } ...
new_inherited
identifier_name
console.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::ConsoleBinding; use dom::bindings::codegen::Bindings::ConsoleBinding::Consol...
{ let global = console.global.root(); let pipelineId = global.r().pipeline(); global.r().devtools_chan().as_ref().map(|chan| { chan.send(ScriptToDevtoolsControlMsg::ConsoleAPI( pipelineId, console_message.clone(), global.r().get_worker_id())).unwrap(); }); }
identifier_body
console.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
use dom::bindings::codegen::Bindings::ConsoleBinding::ConsoleMethods; use dom::bindings::global::{GlobalRef, GlobalField}; use dom::bindings::js::Root; use dom::bindings::utils::{Reflector, reflect_dom_object}; use dom::window::WindowHelpers; use devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg}; ...
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::ConsoleBinding;
random_line_split
userscripts.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::Node...
(head: &HTMLHeadElement) { if let Some(ref path_str) = opts::get().userscripts { let node = head.upcast::<Node>(); let first_child = node.GetFirstChild(); let doc = node.owner_doc(); let doc = doc.r(); let path = if &**path_str == "" { let mut p = resources_dir_p...
load_script
identifier_name
userscripts.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::Node...
for file in files { let name = match file.into_os_string().into_string() { Ok(ref s) if s.ends_with(".js") => "file://".to_owned() + &s[..], _ => continue }; let new_script = doc.CreateElement(DOMString::from("script")).unwrap(); le...
{ let node = head.upcast::<Node>(); let first_child = node.GetFirstChild(); let doc = node.owner_doc(); let doc = doc.r(); let path = if &**path_str == "" { let mut p = resources_dir_path(); p.push("user-agent-js"); p } else { ...
conditional_block
userscripts.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::Node...
for file in files { let name = match file.into_os_string().into_string() { Ok(ref s) if s.ends_with(".js") => "file://".to_owned() + &s[..], _ => continue }; let new_script = doc.CreateElement(DOMString::from("script")).unwrap(); l...
{ if let Some(ref path_str) = opts::get().userscripts { let node = head.upcast::<Node>(); let first_child = node.GetFirstChild(); let doc = node.owner_doc(); let doc = doc.r(); let path = if &**path_str == "" { let mut p = resources_dir_path(); p.push...
identifier_body
userscripts.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::Node...
for file in files { let name = match file.into_os_string().into_string() { Ok(ref s) if s.ends_with(".js") => "file://".to_owned() + &s[..], _ => continue }; let new_script = doc.CreateElement(DOMString::from("script")).unwrap(); le...
files.sort();
random_line_split
match-vec-rvalue.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ match vec!(1, 2, 3) { x => { assert_eq!(x.len(), 3); assert_eq!(*x.get(0), 1); assert_eq!(*x.get(1), 2); assert_eq!(*x.get(2), 3); } } }
identifier_body
match-vec-rvalue.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { match vec!(1, 2, 3) { x => { assert_eq!(x.len(), 3); assert_eq!(*x.get(0), 1); assert_eq!(*x.get(1), 2); assert_eq!(*x.get(2), 3); } } }
main
identifier_name
match-vec-rvalue.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
x => { assert_eq!(x.len(), 3); assert_eq!(*x.get(0), 1); assert_eq!(*x.get(1), 2); assert_eq!(*x.get(2), 3); } } }
pub fn main() { match vec!(1, 2, 3) {
random_line_split
step5_tco.rs
use std::rc::Rc; //use std::collections::HashMap; use fnv::FnvHashMap; use itertools::Itertools; #[macro_use] extern crate lazy_static; extern crate regex; extern crate itertools; extern crate fnv; extern crate rustyline; use rustyline::error::ReadlineError; use rustyline::Editor; #[macro_use] mod types; use types::...
(ast: &MalVal, env: &Env) -> MalRet { match ast { Sym(_) => Ok(env_get(&env, &ast)?), List(v,_) => { let mut lst: MalArgs = vec![]; for a in v.iter() { lst.push(eval(a.clone(), env.clone())?) } Ok(list!(lst)) }, Vector(v,_) => { let mut lst: MalArgs = vec![]; for a in v....
eval_ast
identifier_name
step5_tco.rs
use std::rc::Rc; //use std::collections::HashMap; use fnv::FnvHashMap; use itertools::Itertools; #[macro_use] extern crate lazy_static; extern crate regex; extern crate itertools; extern crate fnv; extern crate rustyline; use rustyline::error::ReadlineError; use rustyline::Editor; #[macro_use] mod types; use types::...
_ => Ok(ast.clone()), } } fn eval(mut ast: MalVal, mut env: Env) -> MalRet { let ret: MalRet; 'tco: loop { ret = match ast.clone() { List(l,_) => { if l.len() == 0 { return Ok(ast); } let a0 = &l[0]; match a0 { Sym(ref a0sym) if a0sym == "def!" => { env_set(&env, ...
{ match ast { Sym(_) => Ok(env_get(&env, &ast)?), List(v,_) => { let mut lst: MalArgs = vec![]; for a in v.iter() { lst.push(eval(a.clone(), env.clone())?) } Ok(list!(lst)) }, Vector(v,_) => { let mut lst: MalArgs = vec![]; for a in v.iter() { lst.push(eval(a.clone(), en...
identifier_body
step5_tco.rs
use std::rc::Rc; //use std::collections::HashMap; use fnv::FnvHashMap; use itertools::Itertools; #[macro_use] extern crate lazy_static; extern crate regex; extern crate itertools; extern crate fnv; extern crate rustyline; use rustyline::error::ReadlineError; use rustyline::Editor; #[macro_use] mod types; use types::...
} } } // vim: ts=2:sw=2:expandtab
random_line_split
chain_api.rs
// Copyright 2021 The Grin Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
// Check query parameters for minimum and maximum search height if let Some(q) = req.uri().query() { let params = QueryParams::from(q); if let Some(h) = params.get("min_height") { let h = h .parse() .map_err(|_| ErrorKind::RequestError("invalid minimum height".into()))?; // Default is genesi...
{ let excess = req .uri() .path() .trim_end_matches('/') .rsplit('/') .next() .ok_or_else(|| ErrorKind::RequestError("missing excess".into()))?; let excess = util::from_hex(excess) .map_err(|_| ErrorKind::RequestError("invalid excess hex".into()))?; if excess.len() != 33 { return Err(Error...
identifier_body
chain_api.rs
// Copyright 2021 The Grin Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
if let Ok(x) = util::from_hex(id) { commitments.push(Commitment::from_vec(x)); } }); let start_height = parse_param!(params, "start_height", 1); let end_height = parse_param!(params, "end_height", 1); let include_rp = params.get("include_rp").is_some(); debug!( "outputs_block_batch: {}-{}, {:?},...
let query = must_get_query!(req); let params = QueryParams::from(query); params.process_multival_param("id", |id| {
random_line_split
chain_api.rs
// Copyright 2021 The Grin Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
{ pub chain: Weak<chain::Chain>, } impl OutputHandler { pub fn get_outputs_v2( &self, commits: Option<Vec<String>>, start_height: Option<u64>, end_height: Option<u64>, include_proof: Option<bool>, include_merkle_proof: Option<bool>, ) -> Result<Vec<OutputPrintable>, Error> { let mut outputs: Vec<Outp...
OutputHandler
identifier_name
chain_api.rs
// Copyright 2021 The Grin Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
} } Ok(return_vec) } // returns outputs for a specified range of blocks fn outputs_block_batch_v2( &self, start_height: u64, end_height: u64, include_rproof: bool, include_merkle_proof: bool, ) -> Result<Vec<OutputPrintable>, Error> { let commitments: Vec<Commitment> = vec![]; debug!( "o...
{ return_vec.push(res); }
conditional_block
lib.rs
// Copyright (c) 2016-2021 Rene van der Meer // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge,...
} impl SerialOutput for BlinktSpi { fn write(&mut self, data: &[u8]) -> Result<()> { self.0.write(data)?; Ok(()) } } /// Interface for the Pimoroni Blinkt!, and any similar APA102 or SK9822 LED /// strips or boards. /// /// By default, Blinkt is set up to communicate with an 8-pixel board th...
{ Self( spi::Spi::new( spi::Bus::Spi0, spi::SlaveSelect::Ss0, 1_000_000, spi::Mode::Mode0, ) .expect("Can't create spi bus"), ) }
identifier_body
lib.rs
// Copyright (c) 2016-2021 Rene van der Meer // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge,...
//! # //! # fn main() -> Result<(), Box<dyn Error>> { //! # let mut blinkt = Blinkt::new()?; //! # //! blinkt.iter_mut().for_each(|pixel| { //! pixel.set_rgb(255, 0, 255); //! }); //! # Ok(()) //! # } //! ``` //! //! For more idiomatic `for` loops, you can access the same iterator //! through a mutable refer...
//! # use std::error::Error; //! # //! # use blinkt::Blinkt;
random_line_split
lib.rs
// Copyright (c) 2016-2021 Rene van der Meer // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge,...
(&mut self, data: &[u8]) -> Result<()> { for byte in data { for n in 0..8 { if (byte & (1 << (7 - n))) > 0 { self.pin_data.set_high(); } else { self.pin_data.set_low(); } self.pin_clock.set_high(...
write
identifier_name