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
estimate_pi.rs
// A very inefficient way to approximate PI using random number. // // with const N: u64 = 100_000_000_000; // ~14mn // pi ~= 3.14159183515999985 // error ~= 0.00000081842979327 extern crate pcgrng; use std::f64; fn main()
{ let mut rng = pcgrng::PCG32::seed(0, 0); const N: u64 = 1_000_000; let mut nb_inside = 0; for _ in 0..N+1 { let (x,y) = (rng.next_f64(), rng.next_f64()); let d = x*x + y*y; // check if randomly select point is inside the circle nb_inside += (d < 1.0) as u64; }; let pi_...
identifier_body
estimate_pi.rs
// A very inefficient way to approximate PI using random number. // // with const N: u64 = 100_000_000_000; // ~14mn // pi ~= 3.14159183515999985 // error ~= 0.00000081842979327 extern crate pcgrng; use std::f64; fn main() { let mut rng = pcgrng::PCG32::seed(0, 0);
let (x,y) = (rng.next_f64(), rng.next_f64()); let d = x*x + y*y; // check if randomly select point is inside the circle nb_inside += (d < 1.0) as u64; }; let pi_estimate = (4 * nb_inside) as f64 / (N as f64); println!("pi ~= {:.17}", pi_estimate); let error = (f64::consts::PI ...
const N: u64 = 1_000_000; let mut nb_inside = 0; for _ in 0..N+1 {
random_line_split
estimate_pi.rs
// A very inefficient way to approximate PI using random number. // // with const N: u64 = 100_000_000_000; // ~14mn // pi ~= 3.14159183515999985 // error ~= 0.00000081842979327 extern crate pcgrng; use std::f64; fn
() { let mut rng = pcgrng::PCG32::seed(0, 0); const N: u64 = 1_000_000; let mut nb_inside = 0; for _ in 0..N+1 { let (x,y) = (rng.next_f64(), rng.next_f64()); let d = x*x + y*y; // check if randomly select point is inside the circle nb_inside += (d < 1.0) as u64; }; let ...
main
identifier_name
stack.rs
//! A lock-free stack which supports concurrent pushes and a concurrent call to //! drain the entire stack all at once. use std::prelude::v1::*; use std::sync::atomic::AtomicUsize; use std::mem; use std::marker; use std::sync::atomic::Ordering::SeqCst; use task::EventSet; pub struct Stack<T> { head: AtomicUsize...
fn drop(&mut self) { for item in self.by_ref() { drop(item); } } } #[cfg(test)] mod tests { use std::prelude::v1::*; use std::rc::Rc; use std::cell::Cell; use super::Stack; struct Set(Rc<Cell<usize>>, usize); impl Drop for Set { fn drop(&mut self) ...
impl<T> Drop for Drain<T> {
random_line_split
stack.rs
//! A lock-free stack which supports concurrent pushes and a concurrent call to //! drain the entire stack all at once. use std::prelude::v1::*; use std::sync::atomic::AtomicUsize; use std::mem; use std::marker; use std::sync::atomic::Ordering::SeqCst; use task::EventSet; pub struct Stack<T> { head: AtomicUsize...
unsafe { let node = Box::from_raw(self.head); self.head = node.next; return Some(node.data) } } } impl<T> Drop for Drain<T> { fn drop(&mut self) { for item in self.by_ref() { drop(item); } } } #[cfg(test)] mod tests { use...
{ return None }
conditional_block
stack.rs
//! A lock-free stack which supports concurrent pushes and a concurrent call to //! drain the entire stack all at once. use std::prelude::v1::*; use std::sync::atomic::AtomicUsize; use std::mem; use std::marker; use std::sync::atomic::Ordering::SeqCst; use task::EventSet; pub struct Stack<T> { head: AtomicUsize...
<T> { head: *mut Node<T>, } impl<T> Stack<T> { pub fn new() -> Stack<T> { Stack { head: AtomicUsize::new(0), _marker: marker::PhantomData, } } pub fn push(&self, data: T) { let mut node = Box::new(Node { data: data, next: 0 as *mut _ }); let mut ...
Drain
identifier_name
stack.rs
//! A lock-free stack which supports concurrent pushes and a concurrent call to //! drain the entire stack all at once. use std::prelude::v1::*; use std::sync::atomic::AtomicUsize; use std::mem; use std::marker; use std::sync::atomic::Ordering::SeqCst; use task::EventSet; pub struct Stack<T> { head: AtomicUsize...
} impl<T> Iterator for Drain<T> { type Item = T; fn next(&mut self) -> Option<T> { if self.head.is_null() { return None } unsafe { let node = Box::from_raw(self.head); self.head = node.next; return Some(node.data) } } } impl...
{ self.drain(); }
identifier_body
windowing.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/. */ //! Abstract windowing methods. The concrete implementations of these can be found in `platform/`. use compositor...
{ Forward, Back, } /// Events that the windowing system sends to Servo. #[derive(Clone)] pub enum WindowEvent { /// Sent when no message has arrived, but the event loop was kicked for some reason (perhaps /// by another Servo subsystem). /// /// FIXME(pcwalton): This is kind of ugly and may no...
WindowNavigateMsg
identifier_name
windowing.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/. */ //! Abstract windowing methods. The concrete implementations of these can be found in `platform/`. use compositor...
/// Sets the load data for the current page. fn set_page_url(&self, url: ServoUrl); /// Called when the browser chrome should display a status message. fn status(&self, Option<String>); /// Called when the browser has started loading a frame. fn load_start(&self, back: bool, forward: bool); ...
fn set_page_title(&self, title: Option<String>);
random_line_split
select_handler.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/. */ /// /// Implementation of the callbacks that the CSS selector engine uses to query the DOM. /// use dom::node::Ab...
pub struct NodeSelectHandler { node: AbstractNode } fn with_node_name<R>(node: AbstractNode, f: &fn(&str) -> R) -> R { if!node.is_element() { fail!(~"attempting to style non-element node"); } do node.with_imm_element |element_n| { f(element_n.tag_name) } } impl SelectHandler<Abstr...
use core::str::eq_slice;
random_line_split
select_handler.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/. */ /// /// Implementation of the callbacks that the CSS selector engine uses to query the DOM. /// use dom::node::Ab...
(&self, node: &AbstractNode, name: &str) -> Option<AbstractNode> { match node.parent_node() { Some(parent) => { do with_node_name(parent) |node_name| { if eq_slice(name, node_name) { Some(parent) } else { ...
named_parent_node
identifier_name
select_handler.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/. */ /// /// Implementation of the callbacks that the CSS selector engine uses to query the DOM. /// use dom::node::Ab...
// TODO: Use a Bloom filter. fn named_ancestor_node(&self, node: &AbstractNode, name: &str) -> Option<AbstractNode> { let mut node = *node; loop { let parent = node.parent_node(); match parent { Some(parent) => { let mut found = false...
{ node.parent_node() }
identifier_body
json.rs
//! Experimental loader which takes a program specification in Json form. use crate::architecture::*; use crate::loader::*; use crate::memory::backing::*; use crate::memory::MemoryPermissions; use serde_json::Value; use std::fs::File; use std::io::Read; use std::path::Path; /// Experimental loader which takes a progr...
}
{ Vec::new() }
identifier_body
json.rs
//! Experimental loader which takes a program specification in Json form. use crate::architecture::*; use crate::loader::*; use crate::memory::backing::*; use crate::memory::MemoryPermissions; use serde_json::Value; use std::fs::File; use std::io::Read; use std::path::Path; /// Experimental loader which takes a progr...
(&self) -> Result<Memory> { Ok(self.memory.clone()) } fn function_entries(&self) -> Result<Vec<FunctionEntry>> { Ok(self.function_entries.clone()) } fn program_entry(&self) -> u64 { self.entry } fn architecture(&self) -> &dyn Architecture { self.architecture.as...
memory
identifier_name
json.rs
//! Experimental loader which takes a program specification in Json form. use crate::architecture::*; use crate::loader::*; use crate::memory::backing::*; use crate::memory::MemoryPermissions; use serde_json::Value; use std::fs::File; use std::io::Read; use std::path::Path; /// Experimental loader which takes a progr...
function_entries.push(FunctionEntry::new(address, Some(name))); } } else { bail!("functions missing"); } let mut memory = Memory::new(architecture.endian()); if let Value::Array(ref segments) = root["segments"] { for segment in segment...
random_line_split
test.rs
use common; use token; use sourcefile; use assembler::definition as definition_assembler; #[test] fn empty() { assert("test_code/roo/definition/Empty.roo", "test_code/java/definition/Empty.java"); } #[test] fn record() { assert("test_code/roo/definition/Record.roo", "test_code/java/definition/Record.java"); }...
} } fn assert_output(output: String, file: &str) { let code = common::read_file(file); assert!(output == code, "expecting compiled code to be \n'{}'\n, got \n'{}'\n", code, output); }
random_line_split
test.rs
use common; use token; use sourcefile; use assembler::definition as definition_assembler; #[test] fn empty() { assert("test_code/roo/definition/Empty.roo", "test_code/java/definition/Empty.java"); } #[test] fn record() { assert("test_code/roo/definition/Record.roo", "test_code/java/definition/Record.java"); }...
(roo_file: &str, java_file: &str) { let tokens = token::tokenize_string(common::read_file(roo_file), roo_file.to_string()); let sourecfile_result = sourcefile::get_sourcefile(&tokens, 0); match sourecfile_result { Err(e) => panic!("expecting definition result to be valid, got {}", e.error_message()...
assert
identifier_name
test.rs
use common; use token; use sourcefile; use assembler::definition as definition_assembler; #[test] fn empty() { assert("test_code/roo/definition/Empty.roo", "test_code/java/definition/Empty.java"); } #[test] fn record() { assert("test_code/roo/definition/Record.roo", "test_code/java/definition/Record.java"); }...
fn assert_output(output: String, file: &str) { let code = common::read_file(file); assert!(output == code, "expecting compiled code to be \n'{}'\n, got \n'{}'\n", code, output); }
{ let tokens = token::tokenize_string(common::read_file(roo_file), roo_file.to_string()); let sourecfile_result = sourcefile::get_sourcefile(&tokens, 0); match sourecfile_result { Err(e) => panic!("expecting definition result to be valid, got {}", e.error_message()), Ok(sourcefile) => { ...
identifier_body
request.rs
//! DNS requests: the bridge between query and transport. //! //! While the future of the `Query` can be driven by any task, the network //! transports are spawned into a reactor core each as a task of their own. //! Requests and responses are exchanged between them using futures’s sync //! primitives. Each transport h...
lBuilder); impl TransportMessage { /// Sets the message ID to the given value. pub fn set_id(&mut self, id: u16) { self.0.header_mut().set_id(id) } /// Checks whether `answer` is an answer to this message. pub fn is_answer(&self, answer: &Message) -> bool { answer.is_answer(&self.0...
essage(Additiona
identifier_name
request.rs
//! DNS requests: the bridge between query and transport. //! //! While the future of the `Query` can be driven by any task, the network //! transports are spawned into a reactor core each as a task of their own. //! Requests and responses are exchanged between them using futures’s sync //! primitives. Each transport h...
/// the other one is kept by the query request. This way, we don’t need to /// pass the message back when the transport is done which makes a lot easier /// to treat all these cases where values along the way are dropped. In order /// to allow the message being taken out of the lock, the lock’s content is /// an option...
/// Transport messages are always kept wrapped into a pair of bi-locks. One /// of those locks goes into the transport request for use by the transport,
random_line_split
request.rs
//! DNS requests: the bridge between query and transport. //! //! While the future of the `Query` can be driven by any task, the network //! transports are spawned into a reactor core each as a task of their own. //! Requests and responses are exchanged between them using futures’s sync //! primitives. Each transport h...
Returns a bytes slice for sending over datagram transports. pub fn dgram_bytes(&mut self) -> &[u8] { &self.0.preview()[2..] } } //------------ TransportMessageGuard ----------------------------------------- /// A RAII guard for a locked transport message. /// /// This implements both `Deref` and `Der...
self.0.preview() } ///
identifier_body
day_10.rs
#![allow(transmute_ptr_to_ref)] use std::mem; use std::boxed::Box; use std::option::Option; use std::ops::Deref; use std::ops::DerefMut; use std::marker::Copy; use std::clone::Clone; struct Bucket { key: Option<i32>, value: Option<i32>, next: Option<Link> } impl Bucket { fn new(key: i32, value: i32)...
key: None, value: None, next: None } } } struct Link { ptr: *mut Bucket } impl Link { fn new(bucket: Bucket) -> Link { Link { ptr: Box::into_raw(Box::new(bucket)) } } } impl Deref for Link { type Target = Bucket; fn der...
Bucket {
random_line_split
day_10.rs
#![allow(transmute_ptr_to_ref)] use std::mem; use std::boxed::Box; use std::option::Option; use std::ops::Deref; use std::ops::DerefMut; use std::marker::Copy; use std::clone::Clone; struct Bucket { key: Option<i32>, value: Option<i32>, next: Option<Link> } impl Bucket { fn new(key: i32, value: i32)...
(&mut self) -> &mut Bucket { unsafe { mem::transmute(self.ptr) } } } impl Copy for Link { } impl Clone for Link { fn clone(&self) -> Link { Link { ptr: self.ptr } } } const CAPACITY: usize = 16; #[derive(Default)] pub struct Map { size: usize, table: Vec<Link...
deref_mut
identifier_name
day_10.rs
#![allow(transmute_ptr_to_ref)] use std::mem; use std::boxed::Box; use std::option::Option; use std::ops::Deref; use std::ops::DerefMut; use std::marker::Copy; use std::clone::Clone; struct Bucket { key: Option<i32>, value: Option<i32>, next: Option<Link> } impl Bucket { fn new(key: i32, value: i32)...
} pub fn contains(&self, key: i32) -> bool { let index = self.table.capacity() & key as usize; let link = self.iterate(key, index); (*link).key == Some(key) } fn iterate(&self, key: i32, index: usize) -> Link { let mut link = self.table[index]; while (*link).ke...
{ self.size += 1; let mut new_bucket = Bucket::new(key, value); let link = self.table[index]; new_bucket.next = Some(link); self.table[index] = Link::new(new_bucket); }
conditional_block
day_10.rs
#![allow(transmute_ptr_to_ref)] use std::mem; use std::boxed::Box; use std::option::Option; use std::ops::Deref; use std::ops::DerefMut; use std::marker::Copy; use std::clone::Clone; struct Bucket { key: Option<i32>, value: Option<i32>, next: Option<Link> } impl Bucket { fn new(key: i32, value: i32)...
fn iterate(&self, key: i32, index: usize) -> Link { let mut link = self.table[index]; while (*link).key!= Some(key) && (*link).next.is_some() { link = (*link).next.unwrap(); } link } pub fn get(&self, key: i32) -> Option<i32> { let index = self.table.ca...
{ let index = self.table.capacity() & key as usize; let link = self.iterate(key, index); (*link).key == Some(key) }
identifier_body
day_4.rs
use std::borrow::Cow; use std::str::Chars; use std::iter::Peekable; pub fn evaluate<'s>(src: Cow<'s, str>) -> f64 { let mut chars = (*src).chars().peekable(); parse_expression(chars.by_ref()) } fn parse_expression(chars: &mut Peekable<Chars>) -> f64 { let mut result = parse_term(chars.by_ref()); loop ...
} fn parse_term(chars: &mut Peekable<Chars>) -> f64 { let mut result = parse_arg(chars.by_ref()); loop { match chars.peek().cloned() { Some('×') => { chars.next(); result *= parse_arg(chars.by_ref()); }, Some('÷') => { ...
} result
random_line_split
day_4.rs
use std::borrow::Cow; use std::str::Chars; use std::iter::Peekable; pub fn evaluate<'s>(src: Cow<'s, str>) -> f64 { let mut chars = (*src).chars().peekable(); parse_expression(chars.by_ref()) } fn parse_expression(chars: &mut Peekable<Chars>) -> f64 { let mut result = parse_term(chars.by_ref()); loop ...
assert_eq!(evaluate(Cow::Borrowed("(4+10)÷2-3×((4+6)-2)")), -17.0); } }
identifier_body
day_4.rs
use std::borrow::Cow; use std::str::Chars; use std::iter::Peekable; pub fn evaluate<'s>(src: Cow<'s, str>) -> f64 { let mut chars = (*src).chars().peekable(); parse_expression(chars.by_ref()) } fn parse_expression(chars: &mut Peekable<Chars>) -> f64 { let mut result = parse_term(chars.by_ref()); loop ...
{ assert_eq!(evaluate(Cow::Borrowed("4-1")), 3.0); } #[test] fn evaluate_mul() { assert_eq!(evaluate(Cow::Borrowed("5×6")), 30.0); } #[test] fn evaluate_div() { assert_eq!(evaluate(Cow::Borrowed("40÷10")), 4.0); } #[test] fn evaluate_multiple_operations() ...
aluate_sub()
identifier_name
resolve-type-param-in-item-in-trait.rs
// Issue #14603: Check for references to type parameters from the // outer scope (in this case, the trait) used on items in an inner // scope (in this case, the enum). trait TraitA<A> { fn outer(&self) { enum Foo<B> { Variance(A) //~^ ERROR can't use generic parameters from oute...
} trait TraitD<A> { fn outer(&self) { fn foo<B>(a: A) { } //~^ ERROR can't use generic parameters from outer function } } fn main() { }
{ struct Foo<B> { a: A } //~^ ERROR can't use generic parameters from outer function }
identifier_body
resolve-type-param-in-item-in-trait.rs
// Issue #14603: Check for references to type parameters from the // outer scope (in this case, the trait) used on items in an inner // scope (in this case, the enum). trait TraitA<A> { fn outer(&self) { enum Foo<B> { Variance(A) //~^ ERROR can't use generic parameters from oute...
() { }
main
identifier_name
resolve-type-param-in-item-in-trait.rs
// Issue #14603: Check for references to type parameters from the // outer scope (in this case, the trait) used on items in an inner
trait TraitA<A> { fn outer(&self) { enum Foo<B> { Variance(A) //~^ ERROR can't use generic parameters from outer function } } } trait TraitB<A> { fn outer(&self) { struct Foo<B>(A); //~^ ERROR can't use generic parameters from outer functi...
// scope (in this case, the enum).
random_line_split
client_only.rs
extern crate jsonrpc_core; extern crate jsonrpc_core_client; #[macro_use] extern crate jsonrpc_derive; use jsonrpc_core::IoHandler; use jsonrpc_core::futures::{self, TryFutureExt}; use jsonrpc_core_client::transports::local; #[rpc(client)] pub trait Rpc { /// Returns a protocol version #[rpc(name = "protocolVersion...
{ let fut = { let handler = IoHandler::new(); let (client, _rpc_client) = local::connect::<gen_client::Client, _, _>(handler); client .add(5, 6) .map_ok(|res| println!("5 + 6 = {}", res)) }; let _ = futures::executor::block_on(fut); }
identifier_body
client_only.rs
extern crate jsonrpc_core; extern crate jsonrpc_core_client; #[macro_use] extern crate jsonrpc_derive; use jsonrpc_core::IoHandler; use jsonrpc_core::futures::{self, TryFutureExt}; use jsonrpc_core_client::transports::local; #[rpc(client)] pub trait Rpc { /// Returns a protocol version
/// Adds two numbers and returns a result #[rpc(name = "add", alias("callAsyncMetaAlias"))] fn add(&self, a: u64, b: u64) -> Result<u64>; } fn main() { let fut = { let handler = IoHandler::new(); let (client, _rpc_client) = local::connect::<gen_client::Client, _, _>(handler); client .add(5, 6) .map_ok(...
#[rpc(name = "protocolVersion")] fn protocol_version(&self) -> Result<String>;
random_line_split
client_only.rs
extern crate jsonrpc_core; extern crate jsonrpc_core_client; #[macro_use] extern crate jsonrpc_derive; use jsonrpc_core::IoHandler; use jsonrpc_core::futures::{self, TryFutureExt}; use jsonrpc_core_client::transports::local; #[rpc(client)] pub trait Rpc { /// Returns a protocol version #[rpc(name = "protocolVersion...
() { let fut = { let handler = IoHandler::new(); let (client, _rpc_client) = local::connect::<gen_client::Client, _, _>(handler); client .add(5, 6) .map_ok(|res| println!("5 + 6 = {}", res)) }; let _ = futures::executor::block_on(fut); }
main
identifier_name
contract.rs
// PactHash // Written in 2015 by // Andrew Poelstra <apoelstra@wpsoftware.net>
// To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warranty. // // You should have received a copy of the CC0 Public Domain Dedication // along with this sof...
//
random_line_split
contract.rs
// PactHash // Written in 2015 by // Andrew Poelstra <apoelstra@wpsoftware.net> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warranty. // // You s...
(data: &str) -> Result<Nonce, Error> { let bytes = try!(data.from_hex().map_err(Error::Hex)); if bytes.len()!= NONCE_LEN { return Err(Error::BadLength(bytes.len())); } unsafe { use std::{mem, ptr}; let mut ret: [u8; NONCE_LEN] = mem::uninitialized(); ...
from_hex
identifier_name
contract.rs
// PactHash // Written in 2015 by // Andrew Poelstra <apoelstra@wpsoftware.net> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warranty. // // You s...
/// Decode an ASCII string as a contract pub fn from_ascii_str(s: &str, nonce: Nonce) -> Result<Contract, Error> { let bytes = s.as_bytes(); if bytes.len()!= DATA_LEN { Err(Error::BadLength(bytes.len())) } else { Ok(Contract { ty: Type::Text, ...
{ let addr: Address = try!(FromBase58::from_base58check(s).map_err(Error::Base58)); if addr.network != expected_network { return Err(Error::WrongNetwork(addr.network, expected_network)); } Ok(Contract { ty: match addr.ty { address::Type::PubkeyHash...
identifier_body
contract.rs
// PactHash // Written in 2015 by // Andrew Poelstra <apoelstra@wpsoftware.net> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warranty. // // You s...
} } impl fmt::LowerHex for Contract { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // TODO no need to allocate here, I'm just being lazy for ch in &self.serialize()[..] { try!(write!(f, "{:02x}", *ch)); } Ok(()) } }
{ Ok(Contract { ty: Type::Text, nonce: nonce, data: bytes.to_owned() }) }
conditional_block
clone.rs
// Copyright 2012-2013 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-MI...
Some(i) => i, None => cx.span_bug(trait_span, format!("unnamed field in normal struct in `deriving({})`", name)) }; cx.field_imm(field.span, ident, subcall(field)) }).collect::...
let fields = all_fields.iter().map(|field| { let ident = match field.name {
random_line_split
clone.rs
// Copyright 2012-2013 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-MI...
format!("static method in `deriving({})`", name)) } if all_fields.len() >= 1 && all_fields.get(0).name.is_none() { // enum-like let subcalls = all_fields.iter().map(subcall)...
{ let clone_ident = substr.method_ident; let ctor_ident; let all_fields; let subcall = |field: &FieldInfo| cx.expr_method_call(field.span, field.self_, clone_ident, Vec::new()); match *substr.fields { Struct(ref af) => { ctor_ident = substr.type_ident; all_fi...
identifier_body
clone.rs
// Copyright 2012-2013 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-MI...
(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, item: @Item, push: |@Item|) { let inline = cx.meta_word(span, InternedString::new("inline")); let attrs = vec!(cx.attribute(span, inline)); let...
expand_deriving_clone
identifier_name
test_helpers.rs
//! A testing module for Runner/Process traits. //! //! When implementing different pieces of this crate, it was expedient //! to have some testing structs in place. This might also be useful for //! other developers who would want to ensure proper functionality. use std::thread; use std::sync::mpsc; use chan; use std:...
impl TestProcess { /// Create a new TestProcess. pub fn new(runner: TestRunner) -> TestProcess { let (sn, rc) = mpsc::channel(); let (send_runner, recv_runner) = mpsc::channel::<TestRunner>(); // Marid sender/receiver let (signals, sig_recv) = chan::async(); thread::spaw...
random_line_split
test_helpers.rs
//! A testing module for Runner/Process traits. //! //! When implementing different pieces of this crate, it was expedient //! to have some testing structs in place. This might also be useful for //! other developers who would want to ensure proper functionality. use std::thread; use std::sync::mpsc; use chan; use std:...
} impl TestRunner { /// Create a new TestRunner. pub fn new(data: usize, sender: Sender<bool>) -> TestRunner { TestRunner { data: data, sender: sender, } } } impl Runner for TestRunner { fn setup(&mut self) -> Result<(), MaridError> { self.data = 27; ...
{ "a testing error" }
identifier_body
test_helpers.rs
//! A testing module for Runner/Process traits. //! //! When implementing different pieces of this crate, it was expedient //! to have some testing structs in place. This might also be useful for //! other developers who would want to ensure proper functionality. use std::thread; use std::sync::mpsc; use chan; use std:...
(runner: TestRunner) -> TestProcess { let (sn, rc) = mpsc::channel(); let (send_runner, recv_runner) = mpsc::channel::<TestRunner>(); // Marid sender/receiver let (signals, sig_recv) = chan::async(); thread::spawn(move || { let mut runner = Box::new(recv_runner.recv()...
new
identifier_name
cityhash.rs
use std::mem; pub fn cityhash32(mut s: &[u8], len: usize) -> u32 { // mut s: &[u8] if len <= 24 { return if len <= 12 { if len <= 4 { hash32Len0to4(s, len) } else { hash32_len_5_to_12(s, len) } } else { hash32_len_13_to_24(s, len) } } // len > 32 ...
(mut h: u32) -> u32 { h ^= h >> 16; h = h.wrapping_mul(0x85ebca6b); h ^= h >> 13; h = h.wrapping_mul(0xc2b2ae35); h ^= h >> 16; return h; } // Mur is a helper from Murmur3 for combining two 32-bit values. fn mur(mut a: u32, mut h: u32) -> u32 { a = a.wrapping_mul(C1); a = rotate32(a, 17...
fmix
identifier_name
cityhash.rs
use std::mem;
return if len <= 12 { if len <= 4 { hash32Len0to4(s, len) } else { hash32_len_5_to_12(s, len) } } else { hash32_len_13_to_24(s, len) } } // len > 32 let mut h = len as u32; let mut g = (len as u32).wrapping_mul(C1); let mut f = g; let mut a0...
pub fn cityhash32(mut s: &[u8], len: usize) -> u32 { // mut s: &[u8] if len <= 24 {
random_line_split
cityhash.rs
use std::mem; pub fn cityhash32(mut s: &[u8], len: usize) -> u32 { // mut s: &[u8] if len <= 24 { return if len <= 12 { if len <= 4 { hash32Len0to4(s, len) } else { hash32_len_5_to_12(s, len) } } else { hash32_len_13_to_24(s, len) } } // len > 32 ...
// rotate32 is a bitwise rotate fn rotate32(val: u32, shift: u32) -> u32 { if shift == 0 { return val; } return val >> shift | val << (32 - shift) } // Some primes between 2^63 and 2^64 for various uses. pub const K0: u64 = 0xc3a5c85c97cb3127; pub const K1: u64 = 0xb492b66fbe98f273; pub const K2:...
{ (p[0] as u32) | (p[1] as u32) << 8 | (p[2] as u32) << 16 | (p[3] as u32) << 24 }
identifier_body
cityhash.rs
use std::mem; pub fn cityhash32(mut s: &[u8], len: usize) -> u32 { // mut s: &[u8] if len <= 24 { return if len <= 12
else { hash32_len_13_to_24(s, len) } } // len > 32 let mut h = len as u32; let mut g = (len as u32).wrapping_mul(C1); let mut f = g; let mut a0 = rotate32(fetch32(&s[len-4..]).wrapping_mul(C1), 17).wrapping_mul(C2); let mut a1 = rotate32(fetch32(&s[len-8..]).wrapping_mul(C1), 17).wrapping_m...
{ if len <= 4 { hash32Len0to4(s, len) } else { hash32_len_5_to_12(s, len) } }
conditional_block
ec_public_key.rs
// Copyright 2017 Brian Smith <brian@briansmith.org> // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed exc...
} // The length of the longest supported EC public key (P-384). const MAX_LEN: usize = 1 + (2 * 48); impl ECPublicKey { // DNSSEC encodes uncompressed EC public keys without the standard 0x04 // prefix that indicates they are uncompressed, but crypto libraries // require that prefix. pub fn from_unpre...
random_line_split
ec_public_key.rs
// Copyright 2017 Brian Smith <brian@briansmith.org> // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed exc...
{ buf: [u8; MAX_LEN], len: usize, } // The length of the longest supported EC public key (P-384). const MAX_LEN: usize = 1 + (2 * 48); impl ECPublicKey { // DNSSEC encodes uncompressed EC public keys without the standard 0x04 // prefix that indicates they are uncompressed, but crypto libraries //...
ECPublicKey
identifier_name
ec_public_key.rs
// Copyright 2017 Brian Smith <brian@briansmith.org> // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed exc...
pub fn prefixed_bytes(&self) -> &[u8] { &self.buf[..self.len] } #[cfg(feature = "ring")] pub fn unprefixed_bytes(&self) -> &[u8] { &self.buf[1..self.len] } }
{ let field_len = match algorithm { Algorithm::ECDSAP256SHA256 => 32, Algorithm::ECDSAP384SHA384 => 48, _ => return Err("only ECDSAP256SHA256 and ECDSAP384SHA384 are supported by Ec".into()), }; let len = 1 + (2 * field_len); if len - 1 != without_pref...
identifier_body
newtype-struct-drop-run.rs
// Copyright 2013 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 y = @Cell::new(32); { let _x = Foo(y); } assert_eq!(y.get(), 23); }
main
identifier_name
newtype-struct-drop-run.rs
// Copyright 2013 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 y = @Cell::new(32); { let _x = Foo(y); } assert_eq!(y.get(), 23); }
pub fn main() {
random_line_split
newtype-struct-drop-run.rs
// Copyright 2013 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 y = @Cell::new(32); { let _x = Foo(y); } assert_eq!(y.get(), 23); }
identifier_body
body.rs
use url::form_urlencoded; use hyper::Chunk; use mime; use controller::context::BodyContent; pub fn parse_body(content_type: Option<&mime::Mime>, body_data: Chunk) -> Option<BodyContent> { if body_data.is_empty() { None } else { let is_multipart_form_data = if let Some(ref content_mime) = conte...
} else { parse_form_urlencoded(body_data) }; Some(body_parsed) } } fn parse_form_urlencoded(body_data: Chunk) -> BodyContent { let vec: Vec<u8> = body_data.iter().cloned().collect(); form_urlencoded::parse(vec.as_ref()) .map(|(key, value)| (key.to_string(), value...
let body_parsed = if is_multipart_form_data { parse_multipart_form_data(content_type, body_data)
random_line_split
body.rs
use url::form_urlencoded; use hyper::Chunk; use mime; use controller::context::BodyContent; pub fn parse_body(content_type: Option<&mime::Mime>, body_data: Chunk) -> Option<BodyContent> { if body_data.is_empty() { None } else { let is_multipart_form_data = if let Some(ref content_mime) = conte...
mime::Mime>, body_data: Chunk) -> BodyContent { if let Some(boundary) = get_boundary(content_type) { println!("multipart request received, boundary: {}", boundary); } parse_form_urlencoded(body_data) // TODO: this is stub } fn get_boundary(content_type: Option<&mime::Mime>) -> Option<String> { ...
ta(content_type: Option<&
identifier_name
body.rs
use url::form_urlencoded; use hyper::Chunk; use mime; use controller::context::BodyContent; pub fn parse_body(content_type: Option<&mime::Mime>, body_data: Chunk) -> Option<BodyContent> { if body_data.is_empty() { None } else { let is_multipart_form_data = if let Some(ref content_mime) = conte...
nt_type: Option<&mime::Mime>) -> Option<String> { content_type .and_then(|content_mime| { content_mime.get_param(mime::BOUNDARY).map(|boundary|boundary.as_ref().into()) }) }
ary) = get_boundary(content_type) { println!("multipart request received, boundary: {}", boundary); } parse_form_urlencoded(body_data) // TODO: this is stub } fn get_boundary(conte
identifier_body
body.rs
use url::form_urlencoded; use hyper::Chunk; use mime; use controller::context::BodyContent; pub fn parse_body(content_type: Option<&mime::Mime>, body_data: Chunk) -> Option<BodyContent> { if body_data.is_empty() { None } else { let is_multipart_form_data = if let Some(ref content_mime) = conte...
; Some(body_parsed) } } fn parse_form_urlencoded(body_data: Chunk) -> BodyContent { let vec: Vec<u8> = body_data.iter().cloned().collect(); form_urlencoded::parse(vec.as_ref()) .map(|(key, value)| (key.to_string(), value.to_string())) .collect() } // TODO: realize this function // h...
{ parse_form_urlencoded(body_data) }
conditional_block
mayberef.rs
use std::ops::Deref; use self::MaybeRef::*; pub enum MaybeRef<'a, T: 'a> { Ref(&'a T), Val(T), } impl<'a, T: Clone> MaybeRef<'a, T> { pub fn take(self) -> T { match self { Val(t) => t, Ref(t) => t.clone(), } } } impl<'a, T> Deref for MaybeRef<'a, T> { type ...
(&self) -> &T { match *self { Ref(t) => t, Val(ref t) => t, } } } #[cfg(test)] mod test { use super::MaybeRef::*; #[test] fn test() { let x = "foo"; let r = Ref(&x); let v = Val(x); assert_eq!(r.take(), v.take()); } }
deref
identifier_name
mayberef.rs
use std::ops::Deref; use self::MaybeRef::*; pub enum MaybeRef<'a, T: 'a> { Ref(&'a T), Val(T), } impl<'a, T: Clone> MaybeRef<'a, T> { pub fn take(self) -> T { match self { Val(t) => t, Ref(t) => t.clone(), } } } impl<'a, T> Deref for MaybeRef<'a, T> { type ...
}
{ let x = "foo"; let r = Ref(&x); let v = Val(x); assert_eq!(r.take(), v.take()); }
identifier_body
mayberef.rs
use std::ops::Deref; use self::MaybeRef::*; pub enum MaybeRef<'a, T: 'a> { Ref(&'a T), Val(T), } impl<'a, T: Clone> MaybeRef<'a, T> { pub fn take(self) -> T { match self { Val(t) => t, Ref(t) => t.clone(), } } } impl<'a, T> Deref for MaybeRef<'a, T> { type ...
} }
let r = Ref(&x); let v = Val(x); assert_eq!(r.take(), v.take());
random_line_split
bitmap_glyph.rs
use std::ptr::null_mut; use { ffi, Bitmap }; pub struct BitmapGlyph { library_raw: ffi::FT_Library, raw: ffi::FT_BitmapGlyph } impl BitmapGlyph { pub unsafe fn from_raw(library_raw: ffi::FT_Library, raw: ffi::FT_BitmapGlyph) -> Self { ffi::FT_Reference_Library(library_raw); BitmapGlyph { l...
} #[inline(always)] pub fn top(&self) -> i32 { unsafe { (*self.raw).top } } #[inline(always)] pub fn bitmap(&self) -> Bitmap { unsafe { Bitmap::from_raw(&(*self.raw).bitmap) } } #[inline(always)] pub fn raw(&self) -> &ffi::FT_BitmapGlyphRec { ...
pub fn left(&self) -> i32 { unsafe { (*self.raw).left }
random_line_split
bitmap_glyph.rs
use std::ptr::null_mut; use { ffi, Bitmap }; pub struct BitmapGlyph { library_raw: ffi::FT_Library, raw: ffi::FT_BitmapGlyph } impl BitmapGlyph { pub unsafe fn from_raw(library_raw: ffi::FT_Library, raw: ffi::FT_BitmapGlyph) -> Self { ffi::FT_Reference_Library(library_raw); BitmapGlyph { l...
(&self) -> Self { let mut target = null_mut(); let err = unsafe { ffi::FT_Glyph_Copy(self.raw as ffi::FT_Glyph, &mut target) }; if err == ffi::FT_Err_Ok { unsafe { BitmapGlyph::from_raw(self.library_raw, target as ffi::FT_BitmapGlyph) } } else { ...
clone
identifier_name
bitmap_glyph.rs
use std::ptr::null_mut; use { ffi, Bitmap }; pub struct BitmapGlyph { library_raw: ffi::FT_Library, raw: ffi::FT_BitmapGlyph } impl BitmapGlyph { pub unsafe fn from_raw(library_raw: ffi::FT_Library, raw: ffi::FT_BitmapGlyph) -> Self { ffi::FT_Reference_Library(library_raw); BitmapGlyph { l...
#[inline(always)] pub fn top(&self) -> i32 { unsafe { (*self.raw).top } } #[inline(always)] pub fn bitmap(&self) -> Bitmap { unsafe { Bitmap::from_raw(&(*self.raw).bitmap) } } #[inline(always)] pub fn raw(&self) -> &ffi::FT_BitmapGlyphRec { ...
{ unsafe { (*self.raw).left } }
identifier_body
bitmap_glyph.rs
use std::ptr::null_mut; use { ffi, Bitmap }; pub struct BitmapGlyph { library_raw: ffi::FT_Library, raw: ffi::FT_BitmapGlyph } impl BitmapGlyph { pub unsafe fn from_raw(library_raw: ffi::FT_Library, raw: ffi::FT_BitmapGlyph) -> Self { ffi::FT_Reference_Library(library_raw); BitmapGlyph { l...
} }
{ panic!("Failed to drop library") }
conditional_block
refcounted.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/. */ //! A generic, safe mechanism by which DOM objects can be pinned and transferred //! between tasks (or intra-task ...
// hashtable entry. info!("attempt to cleanup an unrecognized reflector"); } } }) } } /// A JSTraceDataOp for tracing reflectors held in LIVE_REFERENCES pub unsafe extern "C" fn trace_refcounted_objects(tracer: *mut JSTracer, ...
// there could be a cleanup message dispatched, then a new // pinned reference obtained and released before the message // is processed, at which point there would be no matching
random_line_split
refcounted.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/. */ //! A generic, safe mechanism by which DOM objects can be pinned and transferred //! between tasks (or intra-task ...
self) -> Root<T> { assert!(LIVE_REFERENCES.with(|ref r| { let r = r.borrow(); let live_references = r.as_ref().unwrap(); self.owner_thread == (&*live_references) as *const _ as *const libc::c_void })); unsafe { Root::new(NonZero::new(self.ptr as *c...
ot(&
identifier_name
refcounted.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/. */ //! A generic, safe mechanism by which DOM objects can be pinned and transferred //! between tasks (or intra-task ...
} } /// Unpin the given DOM object if its refcount is 0. pub fn cleanup(raw_reflectable: TrustedReference) { let TrustedReference(raw_reflectable) = raw_reflectable; LIVE_REFERENCES.with(|ref r| { let r = r.borrow(); let live_references = r.as_ref().unwrap(); ...
let refcount = Arc::new(Mutex::new(1)); entry.insert(refcount.clone()); refcount }
conditional_block
refcounted.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/. */ //! A generic, safe mechanism by which DOM objects can be pinned and transferred //! between tasks (or intra-task ...
info!("attempt to cleanup an unrecognized reflector"); } } }) } } /// A JSTraceDataOp for tracing reflectors held in LIVE_REFERENCES pub unsafe extern "C" fn trace_refcounted_objects(tracer: *mut JSTracer, _d...
let TrustedReference(raw_reflectable) = raw_reflectable; LIVE_REFERENCES.with(|ref r| { let r = r.borrow(); let live_references = r.as_ref().unwrap(); let mut table = live_references.table.borrow_mut(); match table.entry(raw_reflectable) { ...
identifier_body
address.rs
//! Ethereum address use std::str::FromStr; use std::fmt; use utils::bigint::M256; use utils::{read_hex, ParseHexError}; use rlp::{Encodable, RlpStream}; #[derive(Eq, PartialEq, Debug, Copy, Clone, Hash)] /// Represents an Ethereum address. This address is 20 bytes long. pub struct Address([u8; 20]); impl Address { ...
}
{ for i in 0..20 { write!(f, "{:02X}", self.0[i])?; } Ok(()) }
identifier_body
address.rs
//! Ethereum address use std::str::FromStr; use std::fmt; use utils::bigint::M256; use utils::{read_hex, ParseHexError}; use rlp::{Encodable, RlpStream}; #[derive(Eq, PartialEq, Debug, Copy, Clone, Hash)] /// Represents an Ethereum address. This address is 20 bytes long. pub struct Address([u8; 20]); impl Address { ...
(self) -> [u8; 20] { self.0 } } impl FromStr for Address { type Err = ParseHexError; fn from_str(s: &str) -> Result<Address, ParseHexError> { read_hex(s).and_then(|v| { if v.len() > 20 { Err(ParseHexError::TooLong) } else if v.len() < 20 { ...
into
identifier_name
address.rs
//! Ethereum address use std::str::FromStr; use std::fmt; use utils::bigint::M256; use utils::{read_hex, ParseHexError}; use rlp::{Encodable, RlpStream}; #[derive(Eq, PartialEq, Debug, Copy, Clone, Hash)] /// Represents an Ethereum address. This address is 20 bytes long. pub struct Address([u8; 20]); impl Address { ...
impl Into<[u8; 20]> for Address { fn into(self) -> [u8; 20] { self.0 } } impl FromStr for Address { type Err = ParseHexError; fn from_str(s: &str) -> Result<Address, ParseHexError> { read_hex(s).and_then(|v| { if v.len() > 20 { Err(ParseHexError::TooLong) ...
Address(a) } }
random_line_split
mod.rs
type. #[experimental = "implementation detail of the `format_args!` macro"] pub struct Argument<'a> { formatter: extern "Rust" fn(&Void, &mut Formatter) -> Result, value: &'a Void, } impl<'a> Arguments<'a> { /// When using the format_args!() macro, this function is used to generate the /// Arguments s...
} /// When a format is not otherwise specified, types are formatted by ascribing /// to this trait. There is not an explicit way of selecting this trait to be /// used for formatting, it is only if no other format is specified. #[unstable = "I/O and core have yet to be reconciled"] pub trait Show for Sized? { ///...
{ write(fmt.buf, self) }
identifier_body
mod.rs
type. #[experimental = "implementation detail of the `format_args!` macro"] pub struct Argument<'a> { formatter: extern "Rust" fn(&Void, &mut Formatter) -> Result, value: &'a Void, } impl<'a> Arguments<'a> { /// When using the format_args!() macro, this function is used to generate the /// Arguments s...
(&mut self, s: &str) -> Result { // Make sure there's a fast path up front if self.width.is_none() && self.precision.is_none() { return self.buf.write(s.as_bytes()); } // The `precision` field can be interpreted as a `max-width` for the // string being formatted ...
pad
identifier_name
mod.rs
to one type. #[experimental = "implementation detail of the `format_args!` macro"] pub struct Argument<'a> { formatter: extern "Rust" fn(&Void, &mut Formatter) -> Result, value: &'a Void, } impl<'a> Arguments<'a> { /// When using the format_args!() macro, this function is used to generate the /// Argu...
/// provided needs to be padded /// * precision - the maximum length to emit, the string is truncated if it /// is longer than this length /// /// Notably this function ignored the `flag` parameters #[unstable = "definition may change slightly over time"] pub fn ...
/// * width - the minimum width of what to emit /// * fill/align - what to emit and where to emit it if the string
random_line_split
syntax_test_union.rs
// SYNTAX TEST "Packages/Rust Enhanced/RustEnhanced.sublime-syntax" union Union { //^^^ meta.union storage.type.union //^^^^^^^^^^^ meta.union // ^^^^^ entity.name.union // ^ meta.block punctuation.definition.block.begin f: u32, // ^ meta.union meta.block variable.other.member // ^ meta.union meta.b...
() {} // ^^^^^ meta.function entity.name.function union /*comment*/ U {} // ^^^^^^^^^^^ meta.union comment.block
union
identifier_name
syntax_test_union.rs
// SYNTAX TEST "Packages/Rust Enhanced/RustEnhanced.sublime-syntax" union Union { //^^^ meta.union storage.type.union
// ^ meta.block punctuation.definition.block.begin f: u32, // ^ meta.union meta.block variable.other.member // ^ meta.union meta.block punctuation.separator // ^^^ meta.union meta.block storage.type } // <- meta.union meta.block punctuation.definition.block.end pub union Foo<'a, Y: Baz> // <- stora...
//^^^^^^^^^^^ meta.union // ^^^^^ entity.name.union
random_line_split
syntax_test_union.rs
// SYNTAX TEST "Packages/Rust Enhanced/RustEnhanced.sublime-syntax" union Union { //^^^ meta.union storage.type.union //^^^^^^^^^^^ meta.union // ^^^^^ entity.name.union // ^ meta.block punctuation.definition.block.begin f: u32, // ^ meta.union meta.block variable.other.member // ^ meta.union meta.b...
// ^^^^^ meta.function entity.name.function union /*comment*/ U {} // ^^^^^^^^^^^ meta.union comment.block
{}
identifier_body
u_str.rs
// Copyright 2012-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-MI...
// every char gets either one u16 or two u16, // so this iterator is between 1 or 2 times as // long as the underlying iterator. (low, high.and_then(|n| n.checked_mul(2))) } } impl<'a> Iterator for SplitWhitespace<'a> { type Item = &'a str; fn next(&mut self) -> Option<&'a ...
let (low, high) = self.chars.size_hint();
random_line_split
u_str.rs
// Copyright 2012-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-MI...
: &'a [u16]) -> Utf16Items<'a> { Utf16Items { iter : v.iter() } } /// Iterator adaptor for encoding `char`s to UTF-16. #[derive(Clone)] pub struct Utf16Encoder<I> { chars: I, extra: u16 } impl<I> Utf16Encoder<I> { /// Create a UTF-16 encoder from any `char` iterator. pub fn new(chars: I) -> Utf16E...
items<'a>(v
identifier_name
u_str.rs
// Copyright 2012-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-MI...
l<'a> DoubleEndedIterator for SplitWhitespace<'a> { fn next_back(&mut self) -> Option<&'a str> { self.inner.next_back() } }
.inner.next() } } imp
identifier_body
vote_genesis.rs
//this module spits out a structured vote as json data //save the vote to a file use safex::genesis::key_generation::KeyPair; use utils::get_address_methods::OmniList; use utils::dirs::{make_app_root_dir, touch}; use voting::poll_genesis::PollRound; use voting::validate_genesis::VotingOutcome; use rustc_serialize:...
} #[derive(Clone, RustcDecodable, RustcEncodable)] pub struct VoteHash { pub poll_hash: Vec<u8>, pub vote_message: String, pub vote_msgindex: i32, pub vote_publickey: String, } impl VoteHash { pub fn return_hash(&self) -> String { let encoded = json::encode(&self).unwrap(); let the_sha = Sha256dHash::fro...
{ &self.voter_keys }
identifier_body
vote_genesis.rs
//this module spits out a structured vote as json data //save the vote to a file use safex::genesis::key_generation::KeyPair; use utils::get_address_methods::OmniList; use utils::dirs::{make_app_root_dir, touch}; use voting::poll_genesis::PollRound; use voting::validate_genesis::VotingOutcome; use rustc_serialize:...
let persona = VotePersona::import_keys(); println!("please enter path of the poll you intend to vote on"); let mut path = String::new(); let stdin = io::stdin(); stdin.lock().read_line(&mut path).unwrap(); let path_trim = path.trim_right_matches("\n"); let path = Path::new(&path_trim); ...
random_line_split
vote_genesis.rs
//this module spits out a structured vote as json data //save the vote to a file use safex::genesis::key_generation::KeyPair; use utils::get_address_methods::OmniList; use utils::dirs::{make_app_root_dir, touch}; use voting::poll_genesis::PollRound; use voting::validate_genesis::VotingOutcome; use rustc_serialize:...
(&self, list: &OmniList) -> i32 { list.return_balance(self.vote_publickey.to_string()) } ///returns a VoteRound from a file path pub fn return_votefromfile(path: &Path) -> VoteRound { let display = "a"; let mut file = match OpenOptions::new().read(true).write(false).open(path) { // The `descri...
return_votecount
identifier_name
workerlocation.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::WorkerLocationBinding; use dom::bindings::codegen::Bindings::WorkerLocationB...
{ reflector_: Reflector, url: Url, } impl WorkerLocation { fn new_inherited(url: Url) -> WorkerLocation { WorkerLocation { reflector_: Reflector::new(), url: url, } } pub fn new(global: &WorkerGlobalScope, url: Url) -> Root<WorkerLocation> { reflect...
WorkerLocation
identifier_name
workerlocation.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::WorkerLocationBinding; use dom::bindings::codegen::Bindings::WorkerLocationB...
// https://html.spec.whatwg.org/multipage/#dom-workerlocation-search fn Search(&self) -> USVString { UrlHelper::Search(&self.url) } // https://html.spec.whatwg.org/multipage/#dom-workerlocation-href fn Stringifier(&self) -> DOMString { DOMString::from(self.Href().0) } }
{ UrlHelper::Protocol(&self.url) }
identifier_body
workerlocation.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::WorkerLocationBinding;
use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::bindings::str::{DOMString, USVString}; use dom::urlhelper::UrlHelper; use dom::workerglobalscope::WorkerGlobalScope; use url::Url; // https://html.spec.whatwg.org/multipage/#worker-locations #[dom_struct] pub struct WorkerLocation { reflector_...
use dom::bindings::codegen::Bindings::WorkerLocationBinding::WorkerLocationMethods; use dom::bindings::global::GlobalRef; use dom::bindings::js::Root;
random_line_split
tag_sets.rs
// Copyright 2014 The html5ever Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // 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 http://opensource.org/licenses/MIT>,...
(_: QualName) -> bool { false } #[inline(always)] pub fn full_set(_: QualName) -> bool { true } // FIXME: MathML, SVG declare_tag_set!(pub default_scope = applet caption html table td th marquee object template); declare_tag_set!(pub list_item_scope = default_scope + ol ul); declare_tag_set!(pub button_scope = defaul...
empty_set
identifier_name
tag_sets.rs
// Copyright 2014 The html5ever Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // 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 http://opensource.org/licenses/MIT>,...
// FIXME: MathML, SVG declare_tag_set!(pub default_scope = applet caption html table td th marquee object template); declare_tag_set!(pub list_item_scope = default_scope + ol ul); declare_tag_set!(pub button_scope = default_scope + button); declare_tag_set!(pub table_scope = html table template); declare_tag_set!(pu...
{ true }
identifier_body
tag_sets.rs
// Copyright 2014 The html5ever Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // 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 http://opensource.org/licenses/MIT>,...
frame frameset h1 h2 h3 h4 h5 h6 head header hgroup hr html iframe img input isindex li link listing main marquee menu menuitem meta nav noembed noframes noscript object ol p param plaintext pre script section select source style summary table tbody td template textarea tfoot th thead title tr track ul ...
random_line_split
group_device_list.rs
use dioxus::prelude::*; use dioxus_router::use_route; use fermi::use_read; use homectl_types::group::GroupId; use crate::{app_state::GROUPS_ATOM, device_list::DeviceList, scene_list::SceneList}; #[allow(non_snake_case)] pub fn GroupDeviceList(cx: Scope) -> Element
{ let group_id: GroupId = use_route(&cx).segment("group_id")?.ok()?; let groups = use_read(&cx, GROUPS_ATOM); let (_, group) = groups .iter() .find(|(candidate_group_id, _)| *candidate_group_id == &group_id)?; let name = &group.name; cx.render(rsx! { DeviceList { filte...
identifier_body
group_device_list.rs
use dioxus::prelude::*; use dioxus_router::use_route; use fermi::use_read; use homectl_types::group::GroupId; use crate::{app_state::GROUPS_ATOM, device_list::DeviceList, scene_list::SceneList}; #[allow(non_snake_case)] pub fn
(cx: Scope) -> Element { let group_id: GroupId = use_route(&cx).segment("group_id")?.ok()?; let groups = use_read(&cx, GROUPS_ATOM); let (_, group) = groups .iter() .find(|(candidate_group_id, _)| *candidate_group_id == &group_id)?; let name = &group.name; cx.render(rsx! { ...
GroupDeviceList
identifier_name
group_device_list.rs
use dioxus::prelude::*; use dioxus_router::use_route;
use homectl_types::group::GroupId; use crate::{app_state::GROUPS_ATOM, device_list::DeviceList, scene_list::SceneList}; #[allow(non_snake_case)] pub fn GroupDeviceList(cx: Scope) -> Element { let group_id: GroupId = use_route(&cx).segment("group_id")?.ok()?; let groups = use_read(&cx, GROUPS_ATOM); let (...
use fermi::use_read;
random_line_split
pad.rs
use ffi::*; use caps::Caps; use reference::Reference; use object::Object; use std::ptr; use std::mem; use std::ops::{Deref, DerefMut}; pub struct Pad{ pad: Object } #[derive(Debug)] #[repr(isize)] pub enum LinkReturn{ WrongHierarchy = GST_PAD_LINK_WRONG_HIERARCHY as isize, WasLinked = GST_PAD_LINK_WAS_LI...
} impl ::Transfer<GstPad> for Pad{ unsafe fn transfer(self) -> *mut GstPad{ self.pad.transfer() as *mut GstPad } } impl Reference for Pad{ fn reference(&self) -> Pad{ Pad{ pad: self.pad.reference() } } } impl AsRef<Object> for Pad{ fn as_ref(&self) -> &Object{ &self.pad ...
} pub unsafe fn gst_pad_mut(&mut self) -> *mut GstPad{ self.pad.gst_object_mut() as *mut GstPad }
random_line_split
pad.rs
use ffi::*; use caps::Caps; use reference::Reference; use object::Object; use std::ptr; use std::mem; use std::ops::{Deref, DerefMut}; pub struct Pad{ pad: Object } #[derive(Debug)] #[repr(isize)] pub enum LinkReturn{ WrongHierarchy = GST_PAD_LINK_WRONG_HIERARCHY as isize, WasLinked = GST_PAD_LINK_WAS_LI...
} } pub fn is_linked(&self) -> bool{ unsafe{ let pad: &mut GstPad = mem::transmute(self.gst_pad()); pad.peer!= ptr::null_mut() } } pub fn query_caps(&self, filter: Option<Caps>) -> Option<Caps>{ unsafe{ let caps = gst_pad_query_caps(...
{ Err(mem::transmute(ret as isize)) }
conditional_block
pad.rs
use ffi::*; use caps::Caps; use reference::Reference; use object::Object; use std::ptr; use std::mem; use std::ops::{Deref, DerefMut}; pub struct Pad{ pad: Object } #[derive(Debug)] #[repr(isize)] pub enum LinkReturn{ WrongHierarchy = GST_PAD_LINK_WRONG_HIERARCHY as isize, WasLinked = GST_PAD_LINK_WAS_LI...
(&self) -> bool{ unsafe{ let pad: &mut GstPad = mem::transmute(self.gst_pad()); pad.peer!= ptr::null_mut() } } pub fn query_caps(&self, filter: Option<Caps>) -> Option<Caps>{ unsafe{ let caps = gst_pad_query_caps(self.gst_pad() as *mut GstPad, filter....
is_linked
identifier_name
pad.rs
use ffi::*; use caps::Caps; use reference::Reference; use object::Object; use std::ptr; use std::mem; use std::ops::{Deref, DerefMut}; pub struct Pad{ pad: Object } #[derive(Debug)] #[repr(isize)] pub enum LinkReturn{ WrongHierarchy = GST_PAD_LINK_WRONG_HIERARCHY as isize, WasLinked = GST_PAD_LINK_WAS_LI...
} impl AsRef<Object> for Pad{ fn as_ref(&self) -> &Object{ &self.pad } } impl AsMut<Object> for Pad{ fn as_mut(&mut self) -> &mut Object{ &mut self.pad } } impl From<Pad> for Object{ fn from(b: Pad) -> Object{ b.pad } } impl Deref for Pad{ type Target = Object; ...
{ Pad{ pad: self.pad.reference() } }
identifier_body
visitor.rs
// Copyright 2016 Google Inc. All rights reserved. // // 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 l...
fn anchor_from_sub_span(&self, span: Span, sub: &str) -> Result<VName, String> { let start = self.codemap.lookup_byte_offset(span.lo); let snippet = match self.codemap.span_to_snippet(span) { Ok(s) => s, Err(e) => return Err(format!("{:?}", e)), }; let sub_sta...
self.anchor(&start.fm.name, start_byte, end_byte) } /// Emits the appropriate node and facts for an anchor defined as a substring within a span /// and returns the node's VName
random_line_split
visitor.rs
// Copyright 2016 Google Inc. All rights reserved. // // 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 l...
(&mut self, impl_item: &'v ImplItem) { let old_parent = self.parent_vname.clone(); let def_id = self.tcx.map.local_def_id(impl_item.id); self.parent_vname = Some(self.vname_from_defid(def_id)); walk_impl_item(self, impl_item); self.parent_vname = old_parent; } /// Run o...
visit_impl_item
identifier_name
visitor.rs
// Copyright 2016 Google Inc. All rights reserved. // // 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 l...
} } } } walk_block(self, block); } /// Captures refs and ref/calls fn visit_expr(&mut self, expr: &'v Expr) { if is_from_macro(&expr.span) { return walk_expr(self, expr); } match expr.node { //...
{ if let ExprCall(_, ref args) = base.node { if let ExprLoop(ref block, _) = outer_arms[0].body.node { if let Some(ref expr) = block.expr { if let ExprMatch(_, ref arms, _) = expr.node { ...
conditional_block