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
typeid-intrinsic.rs
// Copyright 2013-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...
}
// check it has a hash let (a, b) = (TypeId::of::<uint>(), TypeId::of::<uint>()); assert_eq!(hash::hash(&a), hash::hash(&b));
random_line_split
typeid-intrinsic.rs
// Copyright 2013-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...
() { unsafe { assert_eq!(intrinsics::type_id::<other1::A>(), other1::id_A()); assert_eq!(intrinsics::type_id::<other1::B>(), other1::id_B()); assert_eq!(intrinsics::type_id::<other1::C>(), other1::id_C()); assert_eq!(intrinsics::type_id::<other1::D>(), other1::id_D()); assert...
main
identifier_name
typeid-intrinsic.rs
// Copyright 2013-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...
assert_eq!(other1::id_F(), other2::id_F()); assert_eq!(other1::id_G(), other2::id_G()); assert_eq!(other1::id_H(), other2::id_H()); assert_eq!(intrinsics::type_id::<int>(), other2::foo::<int>()); assert_eq!(intrinsics::type_id::<int>(), other1::foo::<int>()); assert_eq!(...
{ unsafe { assert_eq!(intrinsics::type_id::<other1::A>(), other1::id_A()); assert_eq!(intrinsics::type_id::<other1::B>(), other1::id_B()); assert_eq!(intrinsics::type_id::<other1::C>(), other1::id_C()); assert_eq!(intrinsics::type_id::<other1::D>(), other1::id_D()); assert_eq...
identifier_body
issue-11709.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 fn main() { // {} would break let _r = {}; let mut slot = None; // `{ test(...); }` would break let _s : S = S{ x: { test(&mut slot); } }; let _b = not(true); }
{ // `panic!(...)` would break panic!("Break the compiler"); }
conditional_block
issue-11709.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 ...
() { // {} would break let _r = {}; let mut slot = None; // `{ test(...); }` would break let _s : S = S{ x: { test(&mut slot); } }; let _b = not(true); }
main
identifier_name
issue-11709.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 ...
{ // {} would break let _r = {}; let mut slot = None; // `{ test(...); }` would break let _s : S = S{ x: { test(&mut slot); } }; let _b = not(true); }
identifier_body
issue-11709.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 ...
// `{ test(...); }` would break let _s : S = S{ x: { test(&mut slot); } }; let _b = not(true); }
random_line_split
recommendation.rs
//! Project Gutenberg etext recommendation utilities. /* * ashurbanipal.web: Rust Rustful-based interface to Ashurbanipal data * Copyright 2015 Tommy M. McGuire * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the F...
(&self, etext_no : Etext) -> Option<Vec<(Etext,Score)>> { self.scored_results(etext_no).map( |mut results| { results.sort_by( |&(_,l),&(_,r)| panic_unless!("recommendation results", option: l.partial_cmp(&r)) ); results }...
sorted_results
identifier_name
recommendation.rs
//! Project Gutenberg etext recommendation utilities. /* * ashurbanipal.web: Rust Rustful-based interface to Ashurbanipal data * Copyright 2015 Tommy M. McGuire *
* This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License ...
* This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. *
random_line_split
recommendation.rs
//! Project Gutenberg etext recommendation utilities. /* * ashurbanipal.web: Rust Rustful-based interface to Ashurbanipal data * Copyright 2015 Tommy M. McGuire * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the F...
}
{ self.scored_results(etext_no).map( |mut results| { results.sort_by( |&(_,l),&(_,r)| panic_unless!("recommendation results", option: l.partial_cmp(&r)) ); results }) }
identifier_body
on_conflict_target_decorations.rs
use crate::backend::{Backend, SupportsOnConflictClause, SupportsOnConflictTargetDecorations}; use crate::expression::Expression; use crate::query_builder::upsert::on_conflict_target::{ConflictTarget, NoConflictTarget}; use crate::query_builder::where_clause::{NoWhereClause, WhereAnd, WhereClause}; use crate::query_buil...
DB: Backend + SupportsOnConflictClause + SupportsOnConflictTargetDecorations, { fn walk_ast(&self, mut out: AstPass<DB>) -> QueryResult<()> { self.target.walk_ast(out.reborrow())?; self.where_clause.walk_ast(out.reborrow())?; Ok(()) } }
random_line_split
on_conflict_target_decorations.rs
use crate::backend::{Backend, SupportsOnConflictClause, SupportsOnConflictTargetDecorations}; use crate::expression::Expression; use crate::query_builder::upsert::on_conflict_target::{ConflictTarget, NoConflictTarget}; use crate::query_builder::where_clause::{NoWhereClause, WhereAnd, WhereClause}; use crate::query_buil...
<T, U> { target: T, where_clause: U, } impl<T, P> DecoratableTarget<P> for T where P: Expression, P::SqlType: BoolOrNullableBool, T: UndecoratedConflictTarget, { type FilterOutput = DecoratedConflictTarget<T, WhereClause<P>>; fn filter_target(self, predicate: P) -> Self::FilterOutput { ...
DecoratedConflictTarget
identifier_name
on_conflict_target_decorations.rs
use crate::backend::{Backend, SupportsOnConflictClause, SupportsOnConflictTargetDecorations}; use crate::expression::Expression; use crate::query_builder::upsert::on_conflict_target::{ConflictTarget, NoConflictTarget}; use crate::query_builder::where_clause::{NoWhereClause, WhereAnd, WhereClause}; use crate::query_buil...
}
{ self.target.walk_ast(out.reborrow())?; self.where_clause.walk_ast(out.reborrow())?; Ok(()) }
identifier_body
aggregates.rs
// Copyright 2016 Mozilla
// 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 agreed to in writing, software distributed // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR // CONDITIONS OF ANY...
// // Licensed under the Apache License, Version 2.0 (the "License"); you may not use
random_line_split
aggregates.rs
// Copyright 2016 Mozilla // // 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 agreed to in writing, software...
let schema = prepopulated_schema(); let query = r#"[:find (the?e)?a :where [?e :foo/age?a]]"#; // While the query itself algebrizes and parses… let parsed = parse_find_string(query).expect("query input to have parsed"); let algebrized = algebrize(Known::for...
_the_without_max_or_min() {
identifier_name
aggregates.rs
// Copyright 2016 Mozilla // // 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 agreed to in writing, software...
schema } #[test] fn test_aggregate_unsuitable_type() { let schema = prepopulated_schema(); let query = r#"[:find (avg?e) :where [?e :foo/age?a]]"#; // While the query itself algebrizes and parses… let parsed = parse_find_string(query).expect("query input t...
{ let mut schema = Schema::default(); associate_ident(&mut schema, Keyword::namespaced("foo", "name"), 65); associate_ident(&mut schema, Keyword::namespaced("foo", "age"), 68); associate_ident(&mut schema, Keyword::namespaced("foo", "height"), 69); add_attribute(&mut schema, 65, Attribute { ...
identifier_body
std-uncopyable-atomics.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 ...
let x = INIT_ATOMIC_BOOL; let x = *&x; //~ ERROR: cannot move out of dereference let x = INIT_ATOMIC_INT; let x = *&x; //~ ERROR: cannot move out of dereference let x = INIT_ATOMIC_UINT; let x = *&x; //~ ERROR: cannot move out of dereference let x: AtomicPtr<uint> = AtomicPtr::new(ptr::mut_n...
fn main() { let x = INIT_ATOMIC_FLAG; let x = *&x; //~ ERROR: cannot move out of dereference
random_line_split
std-uncopyable-atomics.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 ...
() { let x = INIT_ATOMIC_FLAG; let x = *&x; //~ ERROR: cannot move out of dereference let x = INIT_ATOMIC_BOOL; let x = *&x; //~ ERROR: cannot move out of dereference let x = INIT_ATOMIC_INT; let x = *&x; //~ ERROR: cannot move out of dereference let x = INIT_ATOMIC_UINT; let x = *&x; //...
main
identifier_name
std-uncopyable-atomics.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 ...
{ let x = INIT_ATOMIC_FLAG; let x = *&x; //~ ERROR: cannot move out of dereference let x = INIT_ATOMIC_BOOL; let x = *&x; //~ ERROR: cannot move out of dereference let x = INIT_ATOMIC_INT; let x = *&x; //~ ERROR: cannot move out of dereference let x = INIT_ATOMIC_UINT; let x = *&x; //~ E...
identifier_body
sms_send_verification_code.rs
extern crate open189; fn main() { let args: Vec<_> = std::env::args().collect(); if args.len() < 6 { println!("usage: {} <app id> <secret> <access token> <phone> <code> <expire time>", args[0]); std::process::exit(1); } let app_id = &args[1]; let secret = &args[2]...
; let app = open189::Open189App::new(app_id, secret); let sms_token = app.sms_get_token(access_token); println!("sms token = {:?}", sms_token); let sms_token = sms_token.unwrap(); let config = open189::SmsCodeConfig::prepared(phone, code, expire_time); let result = app.sms_send_verification_c...
{ Some(args[6].parse().unwrap()) }
conditional_block
sms_send_verification_code.rs
extern crate open189; fn main() { let args: Vec<_> = std::env::args().collect(); if args.len() < 6 { println!("usage: {} <app id> <secret> <access token> <phone> <code> <expire time>", args[0]); std::process::exit(1); } let app_id = &args[1]; let secret = &args[2]...
}
let config = open189::SmsCodeConfig::prepared(phone, code, expire_time); let result = app.sms_send_verification_code(access_token, &sms_token, config); println!("send result = {:?}", result);
random_line_split
sms_send_verification_code.rs
extern crate open189; fn main()
let sms_token = app.sms_get_token(access_token); println!("sms token = {:?}", sms_token); let sms_token = sms_token.unwrap(); let config = open189::SmsCodeConfig::prepared(phone, code, expire_time); let result = app.sms_send_verification_code(access_token, &sms_token, config); println!("send r...
{ let args: Vec<_> = std::env::args().collect(); if args.len() < 6 { println!("usage: {} <app id> <secret> <access token> <phone> <code> <expire time>", args[0]); std::process::exit(1); } let app_id = &args[1]; let secret = &args[2]; let access_token = &args[3];...
identifier_body
sms_send_verification_code.rs
extern crate open189; fn
() { let args: Vec<_> = std::env::args().collect(); if args.len() < 6 { println!("usage: {} <app id> <secret> <access token> <phone> <code> <expire time>", args[0]); std::process::exit(1); } let app_id = &args[1]; let secret = &args[2]; let access_token = &args[...
main
identifier_name
primitives.rs
use super::defines::*; //TODO: convert to macro with usage //format!(indent!(5, "format:{}"), 6) pub fn tabs(num: usize) -> String { format!("{:1$}", "", TAB_SIZE * num) } pub fn format_block(prefix: &str, suffix: &str, body: &[String]) -> Vec<String> { let mut v = Vec::new(); if!prefix.is_empty() { ...
#[cfg(test)] mod tests { use super::*; #[test] fn test_tabs() { assert_eq!(tabs(0), ""); assert_eq!(tabs(1), TAB); assert_eq!(tabs(2), format!("{0}{0}", TAB)); } #[test] fn test_format_block() { let body = vec!["0 => 1,".into(), "1 => 0,".into()]; let ...
{ body.iter().map(|s| format!("//{}", s)).collect() }
identifier_body
primitives.rs
use super::defines::*; //TODO: convert to macro with usage //format!(indent!(5, "format:{}"), 6) pub fn tabs(num: usize) -> String { format!("{:1$}", "", TAB_SIZE * num) } pub fn format_block(prefix: &str, suffix: &str, body: &[String]) -> Vec<String> { let mut v = Vec::new(); if!prefix.is_empty() { ...
} pub fn comment_block(body: &[String]) -> Vec<String> { body.iter().map(|s| format!("//{}", s)).collect() } #[cfg(test)] mod tests { use super::*; #[test] fn test_tabs() { assert_eq!(tabs(0), ""); assert_eq!(tabs(1), TAB); assert_eq!(tabs(2), format!("{0}{0}", TAB)); } ...
{ let s = format_block_one_line(prefix, suffix, body, outer_separator, inner_separator); vec![s] }
conditional_block
primitives.rs
use super::defines::*; //TODO: convert to macro with usage //format!(indent!(5, "format:{}"), 6) pub fn tabs(num: usize) -> String { format!("{:1$}", "", TAB_SIZE * num) } pub fn format_block(prefix: &str, suffix: &str, body: &[String]) -> Vec<String> { let mut v = Vec::new(); if!prefix.is_empty() { ...
v.push(s); } if!suffix.is_empty() { v.push(suffix.into()); } v } pub fn format_block_one_line( prefix: &str, suffix: &str, body: &[String], outer_separator: &str, inner_separator: &str, ) -> String { let mut s = format!("{}{}", prefix, outer_separator); let m...
for s in body.iter() { let s = format!("{}{}", TAB, s);
random_line_split
primitives.rs
use super::defines::*; //TODO: convert to macro with usage //format!(indent!(5, "format:{}"), 6) pub fn tabs(num: usize) -> String { format!("{:1$}", "", TAB_SIZE * num) } pub fn format_block(prefix: &str, suffix: &str, body: &[String]) -> Vec<String> { let mut v = Vec::new(); if!prefix.is_empty() { ...
() { let body = vec!["0 => 1,".into(), "1 => 0,".into()]; let actual = format_block("match a {", "}", &body); let expected = ["match a {", " 0 => 1,", " 1 => 0,", "}"]; assert_eq!(actual, expected); } #[test] fn test_format_block_smart_width_one_line_outer_separator() ...
test_format_block
identifier_name
task.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
stack_start: stack_top, stack_end: stack_base - stack_size, status: Runnable, } } pub fn load(&self) { sched::set_task_stack_pointer(self.stack_start); stack::set_stack_limit(self.stack_end); } pub fn save(&mut self) { self.stack_start = sched::get_task_stack_pointer(); } ...
random_line_split
task.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
(&mut self) { self.stack_end = 0; } } #[inline(always)] pub unsafe fn task_scheduler() { stack::set_stack_limit(stack::stack_base() - ReservedPivilegedStackSize); Tasks.current_task().save(); Tasks.next_task(); Tasks.current_task().load(); } // TODO(farcaller): this should not actually use stack! // At ...
invalidate
identifier_name
task.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
pub fn set(val: u32) { unsafe { CurrentStackOffset = val }; } } /// Bytes to reserve in privileged stack based on stack size at the time of task::setup() call. static ReservedPivilegedStackSize: u32 = 256; /// Maximum number of tasks. static MaxTasksCount: uint = 4; mod defined_tasks_count { use core::in...
{ unsafe { CurrentStackOffset } }
identifier_body
extern-fail.rs
// http://www.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 // except according to those terms. // ignore-test linked failure // error-pattern:explicit failure // Testing that runtime ...
// 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
random_line_split
extern-fail.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...
{ for _ in range(0, 10u) { task::spawn(proc() { let result = count(5u); println!("result = %?", result); fail!(); }); } }
identifier_body
extern-fail.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...
} fn count(n: uint) -> uint { unsafe { task::deschedule(); rustrt::rust_dbg_call(cb, n) } } fn main() { for _ in range(0, 10u) { task::spawn(proc() { let result = count(5u); println!("result = %?", result); fail!(); }); } }
{ count(data - 1u) + count(data - 1u) }
conditional_block
extern-fail.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...
(n: uint) -> uint { unsafe { task::deschedule(); rustrt::rust_dbg_call(cb, n) } } fn main() { for _ in range(0, 10u) { task::spawn(proc() { let result = count(5u); println!("result = %?", result); fail!(); }); } }
count
identifier_name
applicable_declarations.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/. */ //! Applicable declarations management. use properties::PropertyDeclarationBlock; use rule_tree::{CascadeLevel, S...
(&self) -> u32 { self.order_and_level.order() } /// Returns the cascade level of the block. #[inline] pub fn level(&self) -> CascadeLevel { self.order_and_level.level() } /// Convenience method to consume self and return the source alongside the /// level. #[inline] ...
source_order
identifier_name
applicable_declarations.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/. */ //! Applicable declarations management. use properties::PropertyDeclarationBlock; use rule_tree::{CascadeLevel, S...
}
{ let level = self.level(); (self.source, level) }
identifier_body
applicable_declarations.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/. */ //! Applicable declarations management. use properties::PropertyDeclarationBlock; use rule_tree::{CascadeLevel, S...
pub fn level(&self) -> CascadeLevel { self.order_and_level.level() } /// Convenience method to consume self and return the source alongside the /// level. #[inline] pub fn order_and_level(self) -> (StyleSource, CascadeLevel) { let level = self.level(); (self.source, leve...
/// Returns the cascade level of the block. #[inline]
random_line_split
task_arc_wake.rs
use futures::task::{self, ArcWake, Waker}; use std::panic; use std::sync::{Arc, Mutex}; struct
{ nr_wake: Mutex<i32>, } impl CountingWaker { fn new() -> Self { Self { nr_wake: Mutex::new(0) } } fn wakes(&self) -> i32 { *self.nr_wake.lock().unwrap() } } impl ArcWake for CountingWaker { fn wake_by_ref(arc_self: &Arc<Self>) { let mut lock = arc_self.nr_wake.lock()...
CountingWaker
identifier_name
task_arc_wake.rs
use futures::task::{self, ArcWake, Waker}; use std::panic; use std::sync::{Arc, Mutex}; struct CountingWaker { nr_wake: Mutex<i32>, } impl CountingWaker { fn new() -> Self { Self { nr_wake: Mutex::new(0) } } fn wakes(&self) -> i32 { *self.nr_wake.lock().unwrap() } } impl ArcWake ...
#[test] fn ref_wake_same() { let some_w = Arc::new(CountingWaker::new()); let w1: Waker = task::waker(some_w.clone()); let w2 = task::waker_ref(&some_w); let w3 = w2.clone(); assert!(w1.will_wake(&w2)); assert!(w2.will_wake(&w3)); } #[test] fn proper_refcount_on_wake_panic() { struct Pa...
{ let some_w = Arc::new(CountingWaker::new()); let w1: Waker = task::waker(some_w.clone()); assert_eq!(2, Arc::strong_count(&some_w)); w1.wake_by_ref(); assert_eq!(1, some_w.wakes()); let w2 = w1.clone(); assert_eq!(3, Arc::strong_count(&some_w)); w2.wake_by_ref(); assert_eq!(2, s...
identifier_body
task_arc_wake.rs
use futures::task::{self, ArcWake, Waker}; use std::panic; use std::sync::{Arc, Mutex}; struct CountingWaker { nr_wake: Mutex<i32>, } impl CountingWaker { fn new() -> Self { Self { nr_wake: Mutex::new(0) } } fn wakes(&self) -> i32 { *self.nr_wake.lock().unwrap() } } impl ArcWake ...
#[test] fn proper_refcount_on_wake_panic() { struct PanicWaker; impl ArcWake for PanicWaker { fn wake_by_ref(_arc_self: &Arc<Self>) { panic!("WAKE UP"); } } let some_w = Arc::new(PanicWaker); let w1: Waker = task::waker(some_w.clone()); assert_eq!( "WAKE U...
assert!(w1.will_wake(&w2)); assert!(w2.will_wake(&w3)); }
random_line_split
static.rs
const FILE_GENERIC_READ: DWORD = STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE; static boolnames: &'static [&'static str] = &[
static mut name: SomeType = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; pub static count: u8 = 10; pub const test: &Type = &val; impl Color { pub const WHITE: u32 = 10; } // #1391 pub const XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: NTSTATUS = ...
"bw", "am", "xsb", "xhp", "xenl", "eo", "gn", "hc", "km", "hs", "in", "db", "da", "mir", "msgr", "os", "eslok", "xt", "hz", "ul", "xon", "nxon", "mc5i", "chts", "nrrmc", "npc", "ndscr", "ccc", "bce", "hls", "xhpa", "crxm", "daisy", "xvpa", "sam", "cpix", "lpix", "OTbs", "OTns", "OTnc", "OTMT", "OTNL", "...
random_line_split
mod.rs
extern crate combine; use self::combine::*; use self::combine::combinator::{Many, SepBy}; use self::combine::primitives::{Consumed, Stream}; use std::collections::HashMap; #[derive(Debug, PartialEq, Eq)] pub enum Object { IntObject(i32), Boolean(bool), String(String), VecObject(Vec<Object>), Struc...
(input: State<&str>) -> ParseResult<char, &str> { let (c, input) = try!(any().parse_lazy(input)); let mut back_slash_char = satisfy(|c| "\"\\/bfnrt".chars().find(|x| *x == c).is_some()).map(|c| { match c { '"' => '"', '\\' => '\\', '/' => '/', ...
escaped_char_parser
identifier_name
mod.rs
extern crate combine; use self::combine::*; use self::combine::combinator::{Many, SepBy}; use self::combine::primitives::{Consumed, Stream}; use std::collections::HashMap; #[derive(Debug, PartialEq, Eq)] pub enum Object {
IntObject(i32), Boolean(bool), String(String), VecObject(Vec<Object>), StructVecObject(Vec<HashMap<String, Object>>), RandomText(String), } pub type Section = HashMap<String, Object>; pub type Sections = Vec<Section>; fn title_parser(input: State<&str>) -> ParseResult<String, &str> { betwee...
random_line_split
mod.rs
extern crate combine; use self::combine::*; use self::combine::combinator::{Many, SepBy}; use self::combine::primitives::{Consumed, Stream}; use std::collections::HashMap; #[derive(Debug, PartialEq, Eq)] pub enum Object { IntObject(i32), Boolean(bool), String(String), VecObject(Vec<Object>), Struc...
#[test] fn test_boolean_parser() { test(boolean_parser, "TRUE", true_object); } #[test] fn test_wierd_exception_parser() { let wierd_object : Object = Object::RandomText("wierd".to_string()); test(wierd_exception, "$$wierd", wierd_object); } #[test] fn test_si...
{ test(string_parser, "\"hello \\\"world\\\"\"", "hello \"world\"".to_string()); }
identifier_body
lib.rs
//! Implementation of Rust panics via process aborts //! //! When compared to the implementation via unwinding, this crate is *much* //! simpler! That being said, it's not quite as versatile, but here goes! #![no_std] #![unstable(feature = "panic_abort", issue = "32837")] #![doc(issue_tracker_base_url = "https://githu...
} else if #[cfg(any(target_os = "hermit", all(target_vendor = "fortanix", target_env = "sgx") ))] { unsafe fn abort() ->! { // call std::sys::abort_internal extern "C" { pub fn __rust_abort() ->!; ...
cfg_if::cfg_if! { if #[cfg(unix)] { unsafe fn abort() -> ! { libc::abort(); }
random_line_split
lib.rs
//! Implementation of Rust panics via process aborts //! //! When compared to the implementation via unwinding, this crate is *much* //! simpler! That being said, it's not quite as versatile, but here goes! #![no_std] #![unstable(feature = "panic_abort", issue = "32837")] #![doc(issue_tracker_base_url = "https://githu...
// "Leak" the payload and shim to the relevant abort on the platform in question. #[rustc_std_internal_symbol] pub unsafe extern "C-unwind" fn __rust_start_panic(_payload: *mut &mut dyn BoxMeUp) -> u32 { // Android has the ability to attach a message as part of the abort. #[cfg(target_os = "android")] and...
{ unreachable!() }
identifier_body
lib.rs
//! Implementation of Rust panics via process aborts //! //! When compared to the implementation via unwinding, this crate is *much* //! simpler! That being said, it's not quite as versatile, but here goes! #![no_std] #![unstable(feature = "panic_abort", issue = "32837")] #![doc(issue_tracker_base_url = "https://githu...
() {} #[rustc_std_internal_symbol] #[cfg(all(target_os = "windows", target_env = "gnu", target_arch = "x86"))] pub extern "C" fn rust_eh_unregister_frames() {} }
rust_eh_register_frames
identifier_name
main.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
* KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ use std::{ fs::{self, File}, io::{BufRead, BufReader}, path::Path, }; use ::ndarray::{Array, ArrayD, Axis}; use image::{FilterType, GenericImageView}; use anyh...
random_line_split
main.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
() -> anyhow::Result<()> { let ctx = Context::cpu(0); println!("{}", concat!(env!("CARGO_MANIFEST_DIR"), "/cat.png")); let img = image::open(concat!(env!("CARGO_MANIFEST_DIR"), "/cat.png")) .context("Failed to open cat.png")?; println!("original image dimensions: {:?}", img.dimensions()); /...
main
identifier_name
main.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
]; for e in &tmp { pixels.push(*e); } } let arr = Array::from_shape_vec((224, 224, 3), pixels)?; let arr: ArrayD<f32> = arr.permuted_axes([2, 0, 1]).into_dyn(); // make arr shape as [1, 3, 224, 224] acceptable to resnet let arr = arr.insert_axis(Axis(0)); // ...
{ let ctx = Context::cpu(0); println!("{}", concat!(env!("CARGO_MANIFEST_DIR"), "/cat.png")); let img = image::open(concat!(env!("CARGO_MANIFEST_DIR"), "/cat.png")) .context("Failed to open cat.png")?; println!("original image dimensions: {:?}", img.dimensions()); // for bigger size images...
identifier_body
main.rs
#![deny( missing_debug_implementations, missing_copy_implementations, trivial_casts, trivial_numeric_casts, unused_import_braces, unused_qualifications, unsafe_code, dead_code, unused_results, )] extern crate clap; extern crate rand; extern crate time; extern crate ctrlc; extern cra...
() { let opts = Options::parse(); let cont = Arc::new(RwLock::new(true)); { let host = opts.host.clone(); let port = opts.port; let cont = cont.clone(); ctrlc::set_handler(move || { println!("Ctrl+C received, terminating..."); *cont.write().unwrap() ...
main
identifier_name
main.rs
#![deny( missing_debug_implementations, missing_copy_implementations, trivial_casts, trivial_numeric_casts, unused_import_braces, unused_qualifications, unsafe_code, dead_code, unused_results, )] extern crate clap; extern crate rand; extern crate time; extern crate ctrlc; extern cra...
}
{ println!("Game loop thread failed: {:?}", error); }
conditional_block
main.rs
#![deny( missing_debug_implementations,
unused_import_braces, unused_qualifications, unsafe_code, dead_code, unused_results, )] extern crate clap; extern crate rand; extern crate time; extern crate ctrlc; extern crate serde; extern crate serde_json; extern crate websocket; mod options; pub mod math; pub mod message; pub mod server; use...
missing_copy_implementations, trivial_casts, trivial_numeric_casts,
random_line_split
main.rs
#![deny( missing_debug_implementations, missing_copy_implementations, trivial_casts, trivial_numeric_casts, unused_import_braces, unused_qualifications, unsafe_code, dead_code, unused_results, )] extern crate clap; extern crate rand; extern crate time; extern crate ctrlc; extern cra...
listen(&opts.host, opts.port, tx, &cont); if let Err(error) = game_loop_handle.join() { println!("Game loop thread failed: {:?}", error); } }
{ let opts = Options::parse(); let cont = Arc::new(RwLock::new(true)); { let host = opts.host.clone(); let port = opts.port; let cont = cont.clone(); ctrlc::set_handler(move || { println!("Ctrl+C received, terminating..."); *cont.write().unwrap() = f...
identifier_body
decode.rs
//! Utilities for decoding a C4FM signal into symbols. use bits; use consts; /// Decodes symbol from sample at each symbol instant. #[derive(Copy, Clone)] pub struct Decoder { /// Sample index into current symbol period. pos: usize, /// Decider used for decoding symbol at each symbol instant. decider:...
mthresh: f32, /// Lower threshold. nthresh: f32, } impl Decider { /// Create a new Decider with the given positive threshold, mid threshold, and /// negative threshold. pub fn new(pthresh: f32, mthresh: f32, nthresh: f32) -> Decider { Decider { pthresh: pthresh, ...
/// Upper threshold. pthresh: f32, /// Middle threshold.
random_line_split
decode.rs
//! Utilities for decoding a C4FM signal into symbols. use bits; use consts; /// Decodes symbol from sample at each symbol instant. #[derive(Copy, Clone)] pub struct Decoder { /// Sample index into current symbol period. pos: usize, /// Decider used for decoding symbol at each symbol instant. decider:...
else { bits::Dibit::new(0b11) } } } #[cfg(test)] mod test { use super::*; #[test] fn test_decider() { let d = Decider::new(-0.004, -0.1, -0.196); assert_eq!(d.decide(0.044).bits(), 0b01); assert_eq!(d.decide(-0.052).bits(), 0b00); assert_eq!(d.deci...
{ bits::Dibit::new(0b10) }
conditional_block
decode.rs
//! Utilities for decoding a C4FM signal into symbols. use bits; use consts; /// Decodes symbol from sample at each symbol instant. #[derive(Copy, Clone)] pub struct Decoder { /// Sample index into current symbol period. pos: usize, /// Decider used for decoding symbol at each symbol instant. decider:...
} #[cfg(test)] mod test { use super::*; #[test] fn test_decider() { let d = Decider::new(-0.004, -0.1, -0.196); assert_eq!(d.decide(0.044).bits(), 0b01); assert_eq!(d.decide(-0.052).bits(), 0b00); assert_eq!(d.decide(-0.148).bits(), 0b10); assert_eq!(d.decide(-0.2...
{ if sample > self.pthresh { bits::Dibit::new(0b01) } else if sample > self.mthresh && sample <= self.pthresh { bits::Dibit::new(0b00) } else if sample <= self.mthresh && sample > self.nthresh { bits::Dibit::new(0b10) } else { bits::Dibit::...
identifier_body
decode.rs
//! Utilities for decoding a C4FM signal into symbols. use bits; use consts; /// Decodes symbol from sample at each symbol instant. #[derive(Copy, Clone)] pub struct Decoder { /// Sample index into current symbol period. pos: usize, /// Decider used for decoding symbol at each symbol instant. decider:...
() { let mut d = Decoder::new(Decider::new(0.0, 0.0, 0.0)); assert!(d.feed(0.2099609375000000).is_none()); assert!(d.feed(0.2165222167968750).is_none()); assert!(d.feed(0.2179870605468750).is_none()); assert!(d.feed(0.2152709960937500).is_none()); assert!(d.feed(0.209472...
test_decoder
identifier_name
native.rs
use std::fs::File; use std::io; use std::os::unix::fs::MetadataExt; use std::os::unix::io::AsRawFd; use nix::errno::Errno; use crate::util::io::io_err; mod sys { use nix::libc::c_int; #[link(name = "fallocate")] extern "C" { pub fn native_fallocate(fd: c_int, len: u64) -> c_int; } } pub fn ...
Errno::EINTR => { continue; } e => { return io_err(e.desc()); } }, _ => unreachable!(), } } }
return Ok(false); } Errno::ENOSPC => { return io_err("Out of disk space!"); }
random_line_split
native.rs
use std::fs::File; use std::io; use std::os::unix::fs::MetadataExt; use std::os::unix::io::AsRawFd; use nix::errno::Errno; use crate::util::io::io_err; mod sys { use nix::libc::c_int; #[link(name = "fallocate")] extern "C" { pub fn native_fallocate(fd: c_int, len: u64) -> c_int; } } pub fn ...
pub fn fallocate(f: &File, len: u64) -> io::Result<bool> { // We ignore the len here, if you actually have a u64 max, then you're kinda fucked either way. loop { match unsafe { sys::native_fallocate(f.as_raw_fd(), len) } { 0 => return Ok(true), -1 => match Errno::last() { ...
{ let stat = f.metadata()?; Ok(stat.blocks() * stat.blksize() < stat.size()) }
identifier_body
native.rs
use std::fs::File; use std::io; use std::os::unix::fs::MetadataExt; use std::os::unix::io::AsRawFd; use nix::errno::Errno; use crate::util::io::io_err; mod sys { use nix::libc::c_int; #[link(name = "fallocate")] extern "C" { pub fn native_fallocate(fd: c_int, len: u64) -> c_int; } } pub fn ...
(f: &File, len: u64) -> io::Result<bool> { // We ignore the len here, if you actually have a u64 max, then you're kinda fucked either way. loop { match unsafe { sys::native_fallocate(f.as_raw_fd(), len) } { 0 => return Ok(true), -1 => match Errno::last() { Errno::...
fallocate
identifier_name
native.rs
use std::fs::File; use std::io; use std::os::unix::fs::MetadataExt; use std::os::unix::io::AsRawFd; use nix::errno::Errno; use crate::util::io::io_err; mod sys { use nix::libc::c_int; #[link(name = "fallocate")] extern "C" { pub fn native_fallocate(fd: c_int, len: u64) -> c_int; } } pub fn ...
e => { return io_err(e.desc()); } }, _ => unreachable!(), } } }
{ continue; }
conditional_block
config.rs
use std::io::Read; use std::fs::File; use std::path::PathBuf; use std::env::home_dir; use serde_json; #[derive(Debug, Serialize, Deserialize)] pub struct XyPair { pub x: u32, pub y: u32 } impl XyPair { #[allow(dead_code)] pub fn new (x: u32, y: u32) -> Self { XyPair { x, y } } } #[derive...
serde_json::from_str(&body).expect("Failed to parse config.") }
random_line_split
config.rs
use std::io::Read; use std::fs::File; use std::path::PathBuf; use std::env::home_dir; use serde_json; #[derive(Debug, Serialize, Deserialize)] pub struct XyPair { pub x: u32, pub y: u32 } impl XyPair { #[allow(dead_code)] pub fn new (x: u32, y: u32) -> Self { XyPair { x, y } } } #[derive...
} fn config_path() -> PathBuf { home_dir() .expect("Failed to locate home directory.") .join(".config") .join("scrotrim") .join("config.json") } pub fn read_config() -> Config { let path = config_path(); let mut body = String::new(); let mut file = File::open(&path).expect...
{ Config { resolution: XyPair::new(x, y), screens } }
identifier_body
config.rs
use std::io::Read; use std::fs::File; use std::path::PathBuf; use std::env::home_dir; use serde_json; #[derive(Debug, Serialize, Deserialize)] pub struct XyPair { pub x: u32, pub y: u32 } impl XyPair { #[allow(dead_code)] pub fn new (x: u32, y: u32) -> Self { XyPair { x, y } } } #[derive...
() -> PathBuf { home_dir() .expect("Failed to locate home directory.") .join(".config") .join("scrotrim") .join("config.json") } pub fn read_config() -> Config { let path = config_path(); let mut body = String::new(); let mut file = File::open(&path).expect("Failed to open c...
config_path
identifier_name
mod.rs
use rustc_serialize::json; use std::fmt; use std::rc; use std::collections; use std::any; use super::schema; use super::validators; pub type KeywordResult = Result<Option<validators::BoxedValidator>, schema::SchemaError>; pub type KeywordPair = (Vec<&'static str>, Box<Keyword +'static>); pub type KeywordPairs = Vec<K...
{ let (keys, keyword) = keyword_pair; let consumer = rc::Rc::new(KeywordConsumer { keys: keys.clone(), keyword: keyword }); for key in keys.iter() { map.insert(key, consumer.clone()); } }
identifier_body
mod.rs
use rustc_serialize::json; use std::fmt; use std::rc; use std::collections; use std::any; use super::schema; use super::validators; pub type KeywordResult = Result<Option<validators::BoxedValidator>, schema::SchemaError>; pub type KeywordPair = (Vec<&'static str>, Box<Keyword +'static>); pub type KeywordPairs = Vec<K...
(&self, set: &mut collections::HashSet<&str>) { for key in self.keys.iter() { if set.contains(key) { set.remove(key); } } } } pub fn decouple_keyword(keyword_pair: KeywordPair, map: &mut KeywordMap) { let (keys, keyword) = keyword_...
consume
identifier_name
mod.rs
use rustc_serialize::json; use std::fmt; use std::rc; use std::collections; use std::any; use super::schema; use super::validators; pub type KeywordResult = Result<Option<validators::BoxedValidator>, schema::SchemaError>; pub type KeywordPair = (Vec<&'static str>, Box<Keyword +'static>); pub type KeywordPairs = Vec<K...
} } } pub fn decouple_keyword(keyword_pair: KeywordPair, map: &mut KeywordMap) { let (keys, keyword) = keyword_pair; let consumer = rc::Rc::new(KeywordConsumer { keys: keys.clone(), keyword: keyword }); for key in keys.iter() { map.insert(key, consumer.clone());...
{ set.remove(key); }
conditional_block
mod.rs
use rustc_serialize::json; use std::fmt; use std::rc; use std::collections; use std::any; use super::schema; use super::validators; pub type KeywordResult = Result<Option<validators::BoxedValidator>, schema::SchemaError>; pub type KeywordPair = (Vec<&'static str>, Box<Keyword +'static>); pub type KeywordPairs = Vec<K...
} } } } pub fn decouple_keyword(keyword_pair: KeywordPair, map: &mut KeywordMap) { let (keys, keyword) = keyword_pair; let consumer = rc::Rc::new(KeywordConsumer { keys: keys.clone(), keyword: keyword }); for key in keys.iter() { map.insert(key, consu...
impl KeywordConsumer { pub fn consume(&self, set: &mut collections::HashSet<&str>) { for key in self.keys.iter() { if set.contains(key) { set.remove(key);
random_line_split
object.rs
use libc::c_void; use ffi::object::{self, LLVMObjectFileRef, LLVMSymbolIteratorRef}; use cbox::CBox; use std::fmt; use std::iter::Iterator; use std::marker::PhantomData; use std::mem; use buffer::MemoryBuffer; use util; /// An external object file that has been parsed by LLVLM pub struct ObjectFile { obj: LLVMObj...
} pub struct Symbol<'a> { pub name: &'a str, pub address: *const c_void, pub size: usize } impl<'a> Copy for Symbol<'a> {} impl<'a> Clone for Symbol<'a> { fn clone(&self) -> Symbol<'a> { *self } } impl<'a> fmt::Debug for Symbol<'a> { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Resul...
{ unsafe { object::LLVMDisposeSymbolIterator(self.iter) } }
identifier_body
object.rs
use libc::c_void; use ffi::object::{self, LLVMObjectFileRef, LLVMSymbolIteratorRef}; use cbox::CBox; use std::fmt; use std::iter::Iterator; use std::marker::PhantomData; use std::mem; use buffer::MemoryBuffer; use util; /// An external object file that has been parsed by LLVLM pub struct ObjectFile { obj: LLVMObj...
(&mut self) -> Option<Symbol<'a>> { unsafe { let name = util::to_str(object::LLVMGetSymbolName(self.iter) as *mut i8); let size = object::LLVMGetSymbolSize(self.iter) as usize; let address = object::LLVMGetSymbolAddress(self.iter) as usize; Some(Symbol { ...
next
identifier_name
object.rs
use libc::c_void; use ffi::object::{self, LLVMObjectFileRef, LLVMSymbolIteratorRef}; use cbox::CBox; use std::fmt; use std::iter::Iterator; use std::marker::PhantomData; use std::mem; use buffer::MemoryBuffer; use util; /// An external object file that has been parsed by LLVLM pub struct ObjectFile { obj: LLVMObj...
pub struct Symbol<'a> { pub name: &'a str, pub address: *const c_void, pub size: usize } impl<'a> Copy for Symbol<'a> {} impl<'a> Clone for Symbol<'a> { fn clone(&self) -> Symbol<'a> { *self } } impl<'a> fmt::Debug for Symbol<'a> { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {...
unsafe { object::LLVMDisposeSymbolIterator(self.iter) } } }
random_line_split
object.rs
use libc::c_void; use ffi::object::{self, LLVMObjectFileRef, LLVMSymbolIteratorRef}; use cbox::CBox; use std::fmt; use std::iter::Iterator; use std::marker::PhantomData; use std::mem; use buffer::MemoryBuffer; use util; /// An external object file that has been parsed by LLVLM pub struct ObjectFile { obj: LLVMObj...
else { Ok(ptr.into()) } } } /// Iterate through the symbols in this object fil pub fn symbols(&self) -> Symbols { Symbols { iter: unsafe { object::LLVMGetSymbols(self.obj) }, marker: PhantomData } } } pub struct Symbols<'a> { ...
{ Err(CBox::from("unknown error")) }
conditional_block
trait-cast-generic.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 ...
<T> { x: T, } impl<T> Foo for Bar<T> { } pub fn main() { let a = Bar { x: 1u }; let b = &a as &Foo; }
Bar
identifier_name
trait-cast-generic.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 ...
let b = &a as &Foo; }
random_line_split
reduce.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
{ pub base: BaseAttrsNode, pub axis: Array<IndexExpr>, pub keepdims: bool, pub exclude: bool, pub unbiased: bool, }
VarianceAttrsNode
identifier_name
reduce.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
*/ use crate::ir::attrs::BaseAttrsNode; use crate::ir::PrimExpr; use crate::runtime::array::Array; use tvm_macros::Object; type IndexExpr = PrimExpr; #[repr(C)] #[derive(Object, Debug)] #[ref_name = "ReduceAttrs"] #[type_key = "relay.attrs.ReduceAttrs"] pub struct ReduceAttrsNode { pub base: BaseAttrsNode, ...
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License.
random_line_split
net_error_list.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 https://mozilla.org/MPL/2.0/. */ // see https://github.com/adobe/chromium/blob/master/net/base/net_error_list.h #[allow(dead_code, non_camel_case_...
{ IO_PENDING = 1, FAILED = 2, ABORTED = 3, INVALID_ARGUMENT = 4, INVALID_HANDLE = 5, FILE_NOT_FOUND = 6, TIMED_OUT = 7, FILE_TOO_BIG = 8, UNEXPECTED = 9, ACCESS_DENIED = 10, NOT_IMPLEMENTED = 11, INSUFFICIENT_RESOURCES = 12, OUT_OF_MEMORY = 13, UPLOAD_FILE_CHANGE...
NetError
identifier_name
net_error_list.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 https://mozilla.org/MPL/2.0/. */ // see https://github.com/adobe/chromium/blob/master/net/base/net_error_list.h #[allow(dead_code, non_camel_case_...
SSL_UNSAFE_NEGOTIATION = 128, SSL_WEAK_SERVER_EPHEMERAL_DH_KEY = 129, PROXY_CONNECTION_FAILED = 130, MANDATORY_PROXY_CONFIGURATION_FAILED = 131, PRECONNECT_MAX_SOCKET_LIMIT = 133, SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED = 134, SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY = 135, PROXY_CERTIFICAT...
SSL_BAD_RECORD_MAC_ALERT = 126, PROXY_AUTH_REQUESTED = 127,
random_line_split
mod.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...
.as_slice(), [Number(color as int)], &mut Variables::new()); if s.is_ok() { try!(self.out.write(s.unwrap().as_slice())); return Ok(true) } } Ok(false) } fn attr(&mut self, attr: attr...
.strings .find_equiv(&("setab")) .unwrap()
random_line_split
mod.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...
(&mut self, attr: attr::Attr) -> IoResult<bool> { match attr { attr::ForegroundColor(c) => self.fg(c), attr::BackgroundColor(c) => self.bg(c), _ => { let cap = cap_for_attr(attr); let parm = self.ti.strings.find_equiv(&cap); if ...
attr
identifier_name
trait-bounds-in-arc.rs
// ignore-pretty // Copyright 2013-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 lice...
for pet in arc.iter() { pet.name(|name| { assert!(name[0] == 'a' as u8 && name[1] == 'l' as u8); }) } } fn check_pedigree(arc: Arc<Vec<~Pet:Share+Send>>) { for pet in arc.iter() { assert!(pet.of_good_pedigree()); } }
} fn check_names(arc: Arc<Vec<~Pet:Share+Send>>) {
random_line_split
trait-bounds-in-arc.rs
// ignore-pretty // Copyright 2013-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 lice...
(&self, blk: |&str|) { blk(self.name) } fn num_legs(&self) -> uint { 4 } fn of_good_pedigree(&self) -> bool { self.num_whiskers >= 4 } } impl Pet for Dogge { fn name(&self, blk: |&str|) { blk(self.name) } fn num_legs(&self) -> uint { 4 } fn of_good_pedigree(&self) -> bool { self.bark_decibel...
name
identifier_name
trait-bounds-in-arc.rs
// ignore-pretty // Copyright 2013-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 lice...
{ for pet in arc.iter() { assert!(pet.of_good_pedigree()); } }
identifier_body
mod.rs
use super::Numeric; use std::ops::{Add, Sub, Mul, Div, Rem}; use std::ops; use std::convert; use std::mem::transmute; #[cfg(test)] mod test; #[macro_use] mod macros; pub trait Matrix<N>: Sized { fn nrows(&self) -> usize; fn ncols(&self) -> usize; } //#[cfg(not(simd))]
//pub struct Matrix2<N> //where N: Numeric { pub x1y1: N, pub x2y1: N // , pub x1y2: N, pub x2y2: N // } // // #[cfg(not(simd))] // #[repr(C)] // #[derive(Clone, Copy, Eq, PartialEq, PartialOrd, Debug, Hash)] //pub struct Matrix3<N> //where N: Numeric { pub x1y1: N, pub x2y1: N, pub x3y1:...
//#[repr(C)] //#[derive(Clone, Copy, Eq, PartialEq, PartialOrd, Debug, Hash)]
random_line_split
convex_try_new3d.rs
extern crate nalgebra as na; use na::Point3; use ncollide3d::shape::ConvexHull; fn main()
{ let points = vec![ Point3::new(0.0f32, 0.0, 1.0), Point3::new(0.0, 0.0, -1.0), Point3::new(0.0, 1.0, 0.0), Point3::new(0.0, -1.0, 0.0), Point3::new(1.0, 0.0, 0.0), Point3::new(-1.0, 0.0, 0.0), ]; let indices = vec![ 0, 4, 2, 0, 3, 4, 5, 0, 2, 5, 3, ...
identifier_body
convex_try_new3d.rs
extern crate nalgebra as na; use na::Point3; use ncollide3d::shape::ConvexHull; fn
() { let points = vec![ Point3::new(0.0f32, 0.0, 1.0), Point3::new(0.0, 0.0, -1.0), Point3::new(0.0, 1.0, 0.0), Point3::new(0.0, -1.0, 0.0), Point3::new(1.0, 0.0, 0.0), Point3::new(-1.0, 0.0, 0.0), ]; let indices = vec![ 0, 4, 2, 0, 3, 4, 5, 0, 2, 5, ...
main
identifier_name
convex_try_new3d.rs
extern crate nalgebra as na; use na::Point3; use ncollide3d::shape::ConvexHull; fn main() { let points = vec![ Point3::new(0.0f32, 0.0, 1.0), Point3::new(0.0, 0.0, -1.0), Point3::new(0.0, 1.0, 0.0), Point3::new(0.0, -1.0, 0.0), Point3::new(1.0, 0.0, 0.0), Point3::ne...
}
]; let convex = ConvexHull::try_new(points, &indices).expect("Invalid convex shape."); convex.check_geometry();
random_line_split
release_entry.rs
use hex::*; use regex::Regex; use semver::Version; use std::iter::*; use std::error::{Error}; use url::{Url}; use url::percent_encoding::{percent_decode}; /* Example lines: # SHA256 of the file Name Version Size [delta/full] release% e4548fba3f902e63e3fff36db7cbbd183...
, _ => Err(From::from("Invalid Release Entry string")) } } pub fn parse_entries(content: &str) -> Result<Vec<ReleaseEntry>, Box<Error>> { let mut was_error: Option<Box<Error>> = None; let r: Vec<ReleaseEntry> = content.split("\n").filter_map(|x| { let r = COMMENT.replace_all(x, ""); ...
{ let (sha256, name, version, size, delta_or_full, percent) = (e[0], e[1], e[2], e[3], e[4], e[5]); let mut ret = ReleaseEntry { sha256: [0; 32], is_delta: try!(ReleaseEntry::parse_delta_full(delta_or_full)), filename_or_url: try!(ReleaseEntry::parse_name(name)).to_owned(),...
conditional_block
release_entry.rs
use hex::*; use regex::Regex; use semver::Version; use std::iter::*; use std::error::{Error}; use url::{Url}; use url::percent_encoding::{percent_decode}; /* Example lines: # SHA256 of the file Name Version Size [delta/full] release% e4548fba3f902e63e3fff36db7cbbd183...
#[test] fn parse_should_fail_negative_percentages() { let input = "e4548fba3f902e63e3fff36db7cbbd1837493e21c51f0751e51ee1483ddd0f35 myproject.7z 1.2.3 12345 delta -145%"; ReleaseEntry::parse(input).unwrap_err(); } #[test] fn url_encoded_filenames_should_end_up_decoded() { let input = "e4548fba3...
{ let input = "e4548fba3f902e63e3fff36db7cbbd1837493e21c51f0751e51ee1483ddd0f35 myproject.7z 1.2.3 12345 delta 145%"; ReleaseEntry::parse(input).unwrap_err(); }
identifier_body
release_entry.rs
use hex::*; use regex::Regex; use semver::Version; use std::iter::*; use std::error::{Error}; use url::{Url}; use url::percent_encoding::{percent_decode}; /* Example lines: # SHA256 of the file Name Version Size [delta/full] release% e4548fba3f902e63e3fff36db7cbbd183...
() { let input = "e4548fba3f902e63e3fff36db7cbbd1837493e21c51f0751e51ee1483ddd0f35 myproject.7z 1.2.3 12345 delta -145%"; ReleaseEntry::parse(input).unwrap_err(); } #[test] fn url_encoded_filenames_should_end_up_decoded() { let input = "e4548fba3f902e63e3fff36db7cbbd1837493e21c51f0751e51ee1483ddd0f35...
parse_should_fail_negative_percentages
identifier_name
release_entry.rs
use hex::*; use regex::Regex; use semver::Version; use std::iter::*; use std::error::{Error}; use url::{Url}; use url::percent_encoding::{percent_decode}; /* Example lines: # SHA256 of the file Name Version Size [delta/full] release% e4548fba3f902e63e3fff36db7cbbd183...
pub sha256: [u8; 32], pub filename_or_url: String, pub version: Version, pub length: i64, pub is_delta: bool, pub percentage: i32, } impl Default for ReleaseEntry { fn default() -> ReleaseEntry { ReleaseEntry { filename_or_url: "Foobdar".to_owned(), version: Version::parse("1.0.0").unwrap...
pub struct ReleaseEntry {
random_line_split
htmltrackelement.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::HTMLTrackElementBinding; use dom::bindings::codegen::InheritTypes::HTMLTrack...
#[allow(unrooted_must_root)] pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLTrackElement> { let element = HTMLTrackElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLTrackElementBinding::Wr...
{ HTMLTrackElement { htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLTrackElement, localName, prefix, document) } }
identifier_body
htmltrackelement.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::HTMLTrackElementBinding; use dom::bindings::codegen::InheritTypes::HTMLTrack...
htmlelement: HTMLElement, } impl HTMLTrackElementDerived for EventTarget { fn is_htmltrackelement(&self) -> bool { *self.type_id() == EventTargetTypeId::Node(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTrackElement))) } } impl HTMLTrackElement { fn new_inherited(local...
pub struct HTMLTrackElement {
random_line_split
htmltrackelement.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::HTMLTrackElementBinding; use dom::bindings::codegen::InheritTypes::HTMLTrack...
(&self) -> bool { *self.type_id() == EventTargetTypeId::Node(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTrackElement))) } } impl HTMLTrackElement { fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLTrackElement { HTMLT...
is_htmltrackelement
identifier_name
table_colgroup.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/. */ //! CSS table formatting contexts. #![deny(unsafe_code)] use app_units::Au; use context::LayoutContext; use disp...
fn iterate_through_fragment_border_boxes(&self, _: &mut FragmentBorderBoxIterator, _: i32, _: &Point2D<Au>) {} fn mutate_fragments(&mut self, _: &mut FnMut(&mut Fragment)) {}...
{ panic!("Table column groups can't be containing blocks!") }
identifier_body
table_colgroup.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/. */ //! CSS table formatting contexts. #![deny(unsafe_code)] use app_units::Au; use context::LayoutContext; use disp...
fn collect_stacking_contexts(&mut self, state: &mut StackingContextCollectionState) { self.base.stacking_context_id = state.current_stacking_context_id; self.base.clipping_and_scrolling = Some(state.current_clipping_and_scrolling); } fn repair_style(&mut self, _: &::ServoArc<ComputedValues...
random_line_split
table_colgroup.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/. */ //! CSS table formatting contexts. #![deny(unsafe_code)] use app_units::Au; use context::LayoutContext; use disp...
(&mut self, _: &::ServoArc<ComputedValues>) {} fn compute_overflow(&self) -> Overflow { Overflow::new() } fn generated_containing_block_size(&self, _: OpaqueFlow) -> LogicalSize<Au> { panic!("Table column groups can't be containing blocks!") } fn iterate_through_fragment_border_bo...
repair_style
identifier_name
set_watch_mode.rs
use std::io; use super::super::{WriteTo, WatchMode, WatchModeReader, WriteResult, Reader, ReaderStatus, MessageInner, Message}; #[derive(Debug, Eq, PartialEq, Clone)] pub struct SetWatchMode { mode: WatchMode, } #[derive(Debug)] pub struct SetWatchModeReader { inner: WatchModeReader, } impl SetWatchMode { ...
} impl MessageInner for SetWatchMode { #[inline] fn wrap(self) -> Message { Message::SetWatchMode(self) } } impl Reader<SetWatchMode> for SetWatchModeReader { fn resume<R>(&mut self, input: &mut R) -> io::Result<ReaderStatus<SetWatchMode>> where R: io::Read { let status = self.inner.r...
{ SetWatchModeReader { inner: WatchMode::reader() } }
identifier_body
set_watch_mode.rs
use std::io; use super::super::{WriteTo, WatchMode, WatchModeReader, WriteResult, Reader, ReaderStatus, MessageInner, Message}; #[derive(Debug, Eq, PartialEq, Clone)] pub struct SetWatchMode { mode: WatchMode, } #[derive(Debug)] pub struct SetWatchModeReader { inner: WatchModeReader, } impl SetWatchMode { ...
(mode: WatchMode) -> Self { SetWatchMode { mode } } pub fn mode(&self) -> WatchMode { self.mode } pub fn reader() -> SetWatchModeReader { SetWatchModeReader { inner: WatchMode::reader() } } } impl MessageInner for SetWatchMode { #[inline] fn wrap(self) -> Message {...
new
identifier_name