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
md-butane.rs
// Lumol, an extensible molecular simulation engine // Copyright (C) Lumol's contributors — BSD license //! Testing molecular dynamics of butane use lumol::input::Input; use std::path::Path; use std::sync::Once; static START: Once = Once::new(); #[test] fn bo
{ START.call_once(::env_logger::init); let path = Path::new(file!()).parent() .unwrap() .join("data") .join("md-butane") .join("nve.toml"); let system = Input::new(path).unwrap()....
nds_detection()
identifier_name
md-butane.rs
// Lumol, an extensible molecular simulation engine // Copyright (C) Lumol's contributors — BSD license //! Testing molecular dynamics of butane use lumol::input::Input; use std::path::Path; use std::sync::Once; static START: Once = Once::new(); #[test] fn bonds_detection() {
#[test] fn constant_energy() { START.call_once(::env_logger::init); let path = Path::new(file!()).parent() .unwrap() .join("data") .join("md-butane") .join("nve.toml"); let mut con...
START.call_once(::env_logger::init); let path = Path::new(file!()).parent() .unwrap() .join("data") .join("md-butane") .join("nve.toml"); let system = Input::new(path).unwrap()...
identifier_body
x86_64.rs
use std::mem; use crate::runtime::Imp; extern { fn objc_msgSend(); fn objc_msgSend_stret(); fn objc_msgSendSuper(); fn objc_msgSendSuper_stret(); } pub fn msg_send_fn<R>() -> Imp { // If the size of an object is larger than two eightbytes, it has class MEMORY. // If the type has class MEMORY...
<R>() -> Imp { if mem::size_of::<R>() <= 16 { objc_msgSendSuper } else { objc_msgSendSuper_stret } }
msg_send_super_fn
identifier_name
x86_64.rs
use std::mem; use crate::runtime::Imp; extern { fn objc_msgSend(); fn objc_msgSend_stret(); fn objc_msgSendSuper(); fn objc_msgSendSuper_stret(); } pub fn msg_send_fn<R>() -> Imp { // If the size of an object is larger than two eightbytes, it has class MEMORY. // If the type has class MEMORY...
} else { objc_msgSend_stret } } pub fn msg_send_super_fn<R>() -> Imp { if mem::size_of::<R>() <= 16 { objc_msgSendSuper } else { objc_msgSendSuper_stret } }
// value and passes the address of this storage. // <http://people.freebsd.org/~obrien/amd64-elf-abi.pdf> if mem::size_of::<R>() <= 16 { objc_msgSend
random_line_split
x86_64.rs
use std::mem; use crate::runtime::Imp; extern { fn objc_msgSend(); fn objc_msgSend_stret(); fn objc_msgSendSuper(); fn objc_msgSendSuper_stret(); } pub fn msg_send_fn<R>() -> Imp { // If the size of an object is larger than two eightbytes, it has class MEMORY. // If the type has class MEMORY...
else { objc_msgSend_stret } } pub fn msg_send_super_fn<R>() -> Imp { if mem::size_of::<R>() <= 16 { objc_msgSendSuper } else { objc_msgSendSuper_stret } }
{ objc_msgSend }
conditional_block
x86_64.rs
use std::mem; use crate::runtime::Imp; extern { fn objc_msgSend(); fn objc_msgSend_stret(); fn objc_msgSendSuper(); fn objc_msgSendSuper_stret(); } pub fn msg_send_fn<R>() -> Imp { // If the size of an object is larger than two eightbytes, it has class MEMORY. // If the type has class MEMORY...
{ if mem::size_of::<R>() <= 16 { objc_msgSendSuper } else { objc_msgSendSuper_stret } }
identifier_body
map.rs
use core::ptr; use super::area::PhysMemoryRange; use super::constants::*; use super::page_align; use super::prelude::*; /// Maximum number of ok-to-use entries pub const MAX_OK_ENTRIES: usize = 20; #[rustfmt::skip] fn read_item(index: usize) -> (u64, u64, u32, u32) { let base = (BOOT_TMP_MMAP_BUFFER + 2u64).as_u...
}
MemoryInfo { allocatable: allocatable.0, max_memory, }
random_line_split
map.rs
use core::ptr; use super::area::PhysMemoryRange; use super::constants::*; use super::page_align; use super::prelude::*; /// Maximum number of ok-to-use entries pub const MAX_OK_ENTRIES: usize = 20; #[rustfmt::skip] fn read_item(index: usize) -> (u64, u64, u32, u32) { let base = (BOOT_TMP_MMAP_BUFFER + 2u64).as_u...
() -> MemoryInfo { // load memory map from where out bootloader left it // http://wiki.osdev.org/Detecting_Memory_(x86)#BIOS_Function:_INT_0x15.2C_EAX_.3D_0xE820 let mut allocatable = MemoryRanges::new(); let mut max_memory = 0u64; { let entry_count: u8 = unsafe { ptr::read_vol...
load_memory_map
identifier_name
map.rs
use core::ptr; use super::area::PhysMemoryRange; use super::constants::*; use super::page_align; use super::prelude::*; /// Maximum number of ok-to-use entries pub const MAX_OK_ENTRIES: usize = 20; #[rustfmt::skip] fn read_item(index: usize) -> (u64, u64, u32, u32) { let base = (BOOT_TMP_MMAP_BUFFER + 2u64).as_u...
} else if first_free.is_none() { first_free = Some(i); } } self.0[first_free.expect("No free entries left")] = Some(entry); } fn split_and_write_entry(&mut self, entry: PhysMemoryRange) { // These are permanently reserved for the kernel i...
{ self.0[i] = Some(ok.merge(entry)); return; }
conditional_block
map.rs
use core::ptr; use super::area::PhysMemoryRange; use super::constants::*; use super::page_align; use super::prelude::*; /// Maximum number of ok-to-use entries pub const MAX_OK_ENTRIES: usize = 20; #[rustfmt::skip] fn read_item(index: usize) -> (u64, u64, u32, u32) { let base = (BOOT_TMP_MMAP_BUFFER + 2u64).as_u...
fn split_and_write_entry(&mut self, entry: PhysMemoryRange) { // These are permanently reserved for the kernel if let Some(ok) = entry.above(MEMORY_RESERVED_BELOW) { // These are permanently reserved for the heap if let Some(below) = ok.below(PhysAddr::new(HEAP_START)) { ...
{ let mut first_free = None; for i in 0..MAX_OK_ENTRIES { if let Some(ok) = self.0[i] { if ok.can_merge(entry) { self.0[i] = Some(ok.merge(entry)); return; } } else if first_free.is_none() { f...
identifier_body
encoding.rs
// Copyright (c) 2015, Sam Payson // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and // associated documentation files (the "Software"), to deal in the Software without restriction, // including without limitation the rights to use, copy, modify, merge, publish, dist...
(&mut self) { self.target.sort_fields(); for dep in self.depends.iter_mut() { dep.sort_fields(); } } } pub use encoding::doc_workaround::COMPLETE_ENC; mod doc_workaround { #![allow(missing_docs)] use encoding::*; use encoding::Quantifier::*; // These are indices into COMPLE...
sort_fields
identifier_name
encoding.rs
// Copyright (c) 2015, Sam Payson // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and // associated documentation files (the "Software"), to deal in the Software without restriction, // including without limitation the rights to use, copy, modify, merge, publish, dist...
id: FieldID(2), name: "req_fields".to_string(), quant: Repeated, typ: FIELD_ENCODING_TYP, bounds: None }, FieldEncoding { id:...
], opt_rep_fields: vec![ FieldEncoding {
random_line_split
range-type-infer.rs
// run-pass #![allow(unused_must_use)] // Make sure the type inference for the new range expression work as // good as the old one. Check out issue #21672, #21595 and #21649 for // more details. fn
() { let xs = (0..8).map(|i| i == 1u64).collect::<Vec<_>>(); assert_eq!(xs[1], true); let xs = (0..8).map(|i| 1u64 == i).collect::<Vec<_>>(); assert_eq!(xs[1], true); let xs: Vec<u8> = (0..10).collect(); assert_eq!(xs.len(), 10); for x in 0..10 { x % 2; } for x in 0..100 { x as f32; } ...
main
identifier_name
range-type-infer.rs
// run-pass #![allow(unused_must_use)] // Make sure the type inference for the new range expression work as
// more details. fn main() { let xs = (0..8).map(|i| i == 1u64).collect::<Vec<_>>(); assert_eq!(xs[1], true); let xs = (0..8).map(|i| 1u64 == i).collect::<Vec<_>>(); assert_eq!(xs[1], true); let xs: Vec<u8> = (0..10).collect(); assert_eq!(xs.len(), 10); for x in 0..10 { x % 2; } for x...
// good as the old one. Check out issue #21672, #21595 and #21649 for
random_line_split
range-type-infer.rs
// run-pass #![allow(unused_must_use)] // Make sure the type inference for the new range expression work as // good as the old one. Check out issue #21672, #21595 and #21649 for // more details. fn main()
{ let xs = (0..8).map(|i| i == 1u64).collect::<Vec<_>>(); assert_eq!(xs[1], true); let xs = (0..8).map(|i| 1u64 == i).collect::<Vec<_>>(); assert_eq!(xs[1], true); let xs: Vec<u8> = (0..10).collect(); assert_eq!(xs.len(), 10); for x in 0..10 { x % 2; } for x in 0..100 { x as f32; } ...
identifier_body
regions-variance-contravariant-use-covariant.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// // 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>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Test that a t...
// http://rust-lang.org/COPYRIGHT.
random_line_split
regions-variance-contravariant-use-covariant.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 ...
<'a> { f: &'a int } fn use_<'short,'long>(c: Contravariant<'short>, s: &'short int, l: &'long int, _where:Option<&'short &'long ()>) { // Test whether Contravariant<'short> <: Contravariant<'long>. Since //'short <= 'long, this would be tr...
Contravariant
identifier_name
font_awesome.rs
// Copyright (c) 2020 DDN. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. use crate::generated::css_classes::C; use seed::{prelude::*, virtual_dom::Attrs, *}; pub fn font_awesome_outline<T>(more_attrs: Attrs, icon_name: &str) -> Node<T> { ...
] ] }
At::Href => format!("sprites/{}.svg#{}", sprite_sheet, icon_name), }
random_line_split
font_awesome.rs
// Copyright (c) 2020 DDN. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. use crate::generated::css_classes::C; use seed::{prelude::*, virtual_dom::Attrs, *}; pub fn font_awesome_outline<T>(more_attrs: Attrs, icon_name: &str) -> Node<T> { ...
<T>(sprite_sheet: &str, more_attrs: Attrs, icon_name: &str) -> Node<T> { let mut attrs = class![C.fill_current]; attrs.merge(more_attrs); svg![ attrs, r#use![ class![C.pointer_events_none], attrs! { At::Href => format!("sprites/{}.svg#{}", sprite_shee...
font_awesome_base
identifier_name
font_awesome.rs
// Copyright (c) 2020 DDN. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. use crate::generated::css_classes::C; use seed::{prelude::*, virtual_dom::Attrs, *}; pub fn font_awesome_outline<T>(more_attrs: Attrs, icon_name: &str) -> Node<T>
pub fn font_awesome<T>(more_attrs: Attrs, icon_name: &str) -> Node<T> { font_awesome_base("solid", more_attrs, icon_name) } fn font_awesome_base<T>(sprite_sheet: &str, more_attrs: Attrs, icon_name: &str) -> Node<T> { let mut attrs = class![C.fill_current]; attrs.merge(more_attrs); svg![ attr...
{ font_awesome_base("regular", more_attrs, icon_name) }
identifier_body
parser.rs
#![plugin(peg_syntax_ext)] use std::fmt; use std::collections::HashMap; peg_file! gremlin("gremlin.rustpeg"); pub fn parse(g: &str) -> Result<ParsedGraphQuery, gremlin::ParseError> { let parsed = pre_parse(g); // verify all the steps actually make sense // is it a query to a single vertex or a global que...
} /* generic step used in ParsedGraphQuery will be turned into specific steps */ #[derive(Debug)] pub struct RawStep { pub name: String, pub args: Vec<Arg>, } #[derive(Debug, Display)] pub enum Arg { Integer(i64), Float(f64), String(String), } impl RawStep { pub fn new(name: String, args: Vec...
*/ pub enum Scope { Global, Vertex(Vec<i64>),
random_line_split
parser.rs
#![plugin(peg_syntax_ext)] use std::fmt; use std::collections::HashMap; peg_file! gremlin("gremlin.rustpeg"); pub fn parse(g: &str) -> Result<ParsedGraphQuery, gremlin::ParseError> { let parsed = pre_parse(g); // verify all the steps actually make sense // is it a query to a single vertex or a global que...
{ pub name: String, pub args: Vec<Arg>, } #[derive(Debug, Display)] pub enum Arg { Integer(i64), Float(f64), String(String), } impl RawStep { pub fn new(name: String, args: Vec<Arg>) -> RawStep { RawStep{name:name, args:args} } } impl fmt::Display for RawStep { fn fmt(&self, ...
RawStep
identifier_name
parser.rs
#![plugin(peg_syntax_ext)] use std::fmt; use std::collections::HashMap; peg_file! gremlin("gremlin.rustpeg"); pub fn parse(g: &str) -> Result<ParsedGraphQuery, gremlin::ParseError> { let parsed = pre_parse(g); // verify all the steps actually make sense // is it a query to a single vertex or a global que...
}
{ write!(f, "RawStep {}", self.name) }
identifier_body
config.rs
use std::net::{SocketAddr, SocketAddrV4, SocketAddrV6, Ipv4Addr}; use std::str::FromStr; use std::any::TypeId; use std::mem::swap; use std::time::Duration; use anymap::Map; use anymap::any::{Any, UncheckedAnyExt}; ///HTTP or HTTPS. pub enum Scheme { ///Standard HTTP. Http, ///HTTP with SSL encryption. ...
///Settings for `keep-alive` connections to the server. pub struct KeepAlive { ///How long a `keep-alive` connection may idle before it's forced close. pub timeout: Duration, ///The number of threads in the thread pool that should be kept free from ///idling threads. Connections will be closed if the ...
}
random_line_split
config.rs
use std::net::{SocketAddr, SocketAddrV4, SocketAddrV6, Ipv4Addr}; use std::str::FromStr; use std::any::TypeId; use std::mem::swap; use std::time::Duration; use anymap::Map; use anymap::any::{Any, UncheckedAnyExt}; ///HTTP or HTTPS. pub enum Scheme { ///Standard HTTP. Http, ///HTTP with SSL encryption. ...
() -> Global { Global(GlobalState::None) } } enum GlobalState { None, One(TypeId, Box<Any + Send + Sync>), Many(Map<Any + Send + Sync>), } ///Settings for `keep-alive` connections to the server. pub struct KeepAlive { ///How long a `keep-alive` connection may idle before it's forced close....
default
identifier_name
config.rs
use std::net::{SocketAddr, SocketAddrV4, SocketAddrV6, Ipv4Addr}; use std::str::FromStr; use std::any::TypeId; use std::mem::swap; use std::time::Duration; use anymap::Map; use anymap::any::{Any, UncheckedAnyExt}; ///HTTP or HTTPS. pub enum Scheme { ///Standard HTTP. Http, ///HTTP with SSL encryption. ...
let mut raw = map.as_mut(); unsafe { raw.insert(id, previous_value); } } map.insert(value) } else { unreachable!() } }, GlobalState::Many(ref mut map) => {...
{ match self.0 { GlobalState::None => { *self = Box::new(value).into(); None }, GlobalState::One(id, _) => if id == TypeId::of::<T>() { if let GlobalState::One(_, ref mut previous_value) = self.0 { let mut v ...
identifier_body
workqueue.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 work queue for scheduling units of work across threads in a fork-join fashion. //! //! Data associated with ...
(&mut self) { // Tell the workers to start. let mut work_count = AtomicUint::new(self.work_count); for worker in self.workers.mut_iter() { worker.chan.send(StartMsg(worker.deque.take_unwrap(), &mut work_count, &self.data)) } // Wait for the work to finish. dr...
run
identifier_name
workqueue.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 work queue for scheduling units of work across threads in a fork-join fashion. //! //! Data associated with ...
// // FIXME(pcwalton): Can't use labeled break or continue cross-crate due to a Rust bug. loop { // FIXME(pcwalton): Nasty workaround for the lack of labeled break/continue // cross-crate. let mut work_unit = unsafe { ...
ExitMsg => return, }; // We're off!
random_line_split
workqueue.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 work queue for scheduling units of work across threads in a fork-join fashion. //! //! Data associated with ...
/// Synchronously runs all the enqueued tasks and waits for them to complete. pub fn run(&mut self) { // Tell the workers to start. let mut work_count = AtomicUint::new(self.work_count); for worker in self.workers.mut_iter() { worker.chan.send(StartMsg(worker.deque.take_unw...
{ match self.workers[0].deque { None => { fail!("tried to push a block but we don't have the deque?!") } Some(ref mut deque) => deque.push(work_unit), } self.work_count += 1 }
identifier_body
workqueue.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 work queue for scheduling units of work across threads in a fork-join fashion. //! //! Data associated with ...
} } // Give the deque back to the supervisor. self.chan.send(ReturnDequeMsg(self.index, deque)) } } } /// A handle to the work queue that individual work units have. pub struct WorkerProxy<'a,QUD,WUD> { priv worker: &'a mut Worker<WorkUnit<QUD,WUD>>...
{ self.chan.send(FinishedMsg) }
conditional_block
lib.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/. */ #![feature(alloc)] #![feature(box_syntax)] #![feature(collections)] #![feature(core)] #![feature(plugin)] #![featu...
pub mod font; pub mod font_context; pub mod font_cache_task; pub mod font_template; // Misc. mod buffer_map; mod filters; // Platform-specific implementations. #[path="platform/mod.rs"] pub mod platform; // Text #[path = "text/mod.rs"] pub mod text;
#[path="display_list/mod.rs"] pub mod display_list; pub mod paint_task; // Fonts
random_line_split
TestNativeCosh.rs
/* * Copyright (C) 2014 The Android Open Source Project * * 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 app...
#pragma version(1) #pragma rs java_package_name(android.renderscript.cts) // Don't edit this file! It is auto-generated by frameworks/rs/api/gen_runtime. float __attribute__((kernel)) testNativeCoshFloatFloat(float in) { return native_cosh(in); } float2 __attribute__((kernel)) testNativeCoshFloat2Float2(float...
random_line_split
union-c-interop.rs
// Copyright 2016 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 ...
{ LowPart: u32, HighPart: u32, } #[derive(Clone, Copy)] #[repr(C)] union LARGE_INTEGER { __unnamed__: LARGE_INTEGER_U, u: LARGE_INTEGER_U, QuadPart: u64, } #[link(name = "rust_test_helpers", kind = "static")] extern "C" { fn increment_all_parts(_: LARGE_INTEGER) -> LARGE_INTEGER; } fn main() { ...
LARGE_INTEGER_U
identifier_name
union-c-interop.rs
// Copyright 2016 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 ...
{ unsafe { let mut li = LARGE_INTEGER { QuadPart: 0 }; let li_c = increment_all_parts(li); li.__unnamed__.LowPart += 1; li.__unnamed__.HighPart += 1; li.u.LowPart += 1; li.u.HighPart += 1; li.QuadPart += 1; assert_eq!(li.QuadPart, li_c.QuadPart); }...
identifier_body
union-c-interop.rs
// Copyright 2016 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
// option. This file may not be copied, modified, or distributed // except according to those terms. // run-pass #![allow(non_snake_case)] // ignore-wasm32-bare no libc to test ffi with #[derive(Clone, Copy)] #[repr(C)] struct LARGE_INTEGER_U { LowPart: u32, HighPart: u32, } #[derive(Clone, Copy)] #[repr(C)...
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
kbo.rs
// Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos. // // Serkr 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 3 of the License, or // (at your option) any later ver...
assert!(kbo_gt(&precedence, &weight, &only_unary_func, &f_x, &x)); assert!(kbo_gt(&precedence, &weight, &only_unary_func, &f_f_x, &x)); assert!(!kbo_gt(&precedence, &weight, &only_unary_func, &x, &f_f_x)); assert!(!kbo_gt(&precedence, &weight, &only_unary_func, &x, &f_x)); assert...
let f_f_x = Term::new_function(1, vec![f_x.clone()]); assert!(kbo_gt(&precedence, &weight, &only_unary_func, &f_f_x, &f_x));
random_line_split
kbo.rs
// Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos. // // Serkr 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 3 of the License, or // (at your option) any later ver...
}
{ let precedence = Precedence::default(); let weight = Weight::SimpleWeight; let only_unary_func = Some(1); let x = Term::new_variable(-1); let f_x = Term::new_function(1, vec![x.clone()]); let f_f_x = Term::new_function(1, vec![f_x.clone()]); let f_f_f_x = Term:...
identifier_body
kbo.rs
// Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos. // // Serkr 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 3 of the License, or // (at your option) any later ver...
} else { false } } else if s.is_function() && t.is_variable() { s.occurs_proper(t) } else { false } } /// Checks if s is greater than or equal to t according to the ordering. pub fn kbo_ge(precedence: &Precedence, weight: &Weight, onl...
{ false }
conditional_block
kbo.rs
// Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos. // // Serkr 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 3 of the License, or // (at your option) any later ver...
(precedence: &Precedence, weight: &Weight, only_unary_func: &Option<i64>, s: &Term, t: &Term) -> bool { assert_eq!(s.get_id(), t.get_id()); assert_eq!(s.get_arity(), t.get_arity()); for i in 0..s.get_arity()...
lexical_ordering
identifier_name
lib.rs
/// Generate a secret key for signing and verifying JSON Web Tokens and HMACs. /// /// Returns a secret comprised of 64 URL and command line compatible characters /// (e.g. so that it can easily be entered on the CLI e.g. for a `--key` option ). /// /// Uses 64 bytes because this is the maximum size possible for JWT si...
use rand::Rng; const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz\ 0123456789"; let mut rng = rand::thread_rng(); (0..64) .map(|_| { let idx = rng.gen_range(0..CHARSET.len()); CHARSET[idx]...
/// See <https://auth0.com/blog/brute-forcing-hs256-is-possible-the-importance-of-using-strong-keys-to-sign-jwts/>. pub fn generate() -> String {
random_line_split
lib.rs
/// Generate a secret key for signing and verifying JSON Web Tokens and HMACs. /// /// Returns a secret comprised of 64 URL and command line compatible characters /// (e.g. so that it can easily be entered on the CLI e.g. for a `--key` option ). /// /// Uses 64 bytes because this is the maximum size possible for JWT si...
() -> String { use rand::Rng; const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz\ 0123456789"; let mut rng = rand::thread_rng(); (0..64) .map(|_| { let idx = rng.gen_range(0..CHARSET.len()); ...
generate
identifier_name
lib.rs
/// Generate a secret key for signing and verifying JSON Web Tokens and HMACs. /// /// Returns a secret comprised of 64 URL and command line compatible characters /// (e.g. so that it can easily be entered on the CLI e.g. for a `--key` option ). /// /// Uses 64 bytes because this is the maximum size possible for JWT si...
{ use rand::Rng; const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz\ 0123456789"; let mut rng = rand::thread_rng(); (0..64) .map(|_| { let idx = rng.gen_range(0..CHARSET.len()); CHARSET[i...
identifier_body
hamming.rs
pub fn hamming_dist(a: &[u8], b:&[u8]) -> Option<u32> { use std::iter::{IteratorExt, AdditiveIterator}; if a.len()!=b.len() { return None; } let result = a.iter().zip(b.iter()).map(|(x,y)| {n_ones(x^y) as u32}).sum(); Some(result) } pub fn avg_hamming_dist(entries: &[&[u8]]) -> Option<f32> ...
+ hamming_dist(b,c).unwrap() + hamming_dist(a,c).unwrap()) as f32/3f32)); assert_eq!(avg_hamming_dist(&[a,b,c,d]), None); } }
random_line_split
hamming.rs
pub fn hamming_dist(a: &[u8], b:&[u8]) -> Option<u32> { use std::iter::{IteratorExt, AdditiveIterator}; if a.len()!=b.len()
let result = a.iter().zip(b.iter()).map(|(x,y)| {n_ones(x^y) as u32}).sum(); Some(result) } pub fn avg_hamming_dist(entries: &[&[u8]]) -> Option<f32> { let n = entries.len(); if n==0 {return None}; let mut sum = 0f32; for idx_a in 0..n { for idx_b in (idx_a+1)..n { let a = ...
{ return None; }
conditional_block
hamming.rs
pub fn hamming_dist(a: &[u8], b:&[u8]) -> Option<u32> { use std::iter::{IteratorExt, AdditiveIterator}; if a.len()!=b.len() { return None; } let result = a.iter().zip(b.iter()).map(|(x,y)| {n_ones(x^y) as u32}).sum(); Some(result) } pub fn avg_hamming_dist(entries: &[&[u8]]) -> Option<f32> ...
fn avg_hamming_dist_test() { let a = "this is a test".as_bytes(); let b = "wokka wokka!!!".as_bytes(); let c = "onyonghasayo!!".as_bytes(); let d = "this is not a test".as_bytes(); assert_eq!(avg_hamming_dist(&[a,b,c]), Some((hamming_dist(a,b).unwrap() ...
{ let a = "this is a test".as_bytes(); let b = "wokka wokka!!!".as_bytes(); let c = "this is not a test".as_bytes(); assert_eq!(Some(37), hamming_dist(a,b)); assert_eq!(None, hamming_dist(a,c)); }
identifier_body
hamming.rs
pub fn hamming_dist(a: &[u8], b:&[u8]) -> Option<u32> { use std::iter::{IteratorExt, AdditiveIterator}; if a.len()!=b.len() { return None; } let result = a.iter().zip(b.iter()).map(|(x,y)| {n_ones(x^y) as u32}).sum(); Some(result) } pub fn avg_hamming_dist(entries: &[&[u8]]) -> Option<f32> ...
() { assert_eq!(n_ones(5), 2); } #[cfg(test)] mod tests { use super::*; #[test] fn hamming_dist_test() { let a = "this is a test".as_bytes(); let b = "wokka wokka!!!".as_bytes(); let c = "this is not a test".as_bytes(); assert_eq!(Some(37), hamming_dist(a,b)); a...
n_ones_test
identifier_name
mod.rs
#![cfg(target_os = "emscripten")] use std::ffi::CString; use libc; use {Event, BuilderAttribs, CreationError, MouseCursor}; use Api; use PixelFormat; use GlContext; use std::collections::VecDeque; mod ffi; pub struct Window { context: ffi::EMSCRIPTEN_WEBGL_CONTEXT_HANDLE, } pub struct PollEventsIterator<'a> { ...
(code: ffi::EMSCRIPTEN_RESULT) -> &'static str { match code { ffi::EMSCRIPTEN_RESULT_SUCCESS | ffi::EMSCRIPTEN_RESULT_DEFERRED => "Internal error in the library (success detected as failure)", ffi::EMSCRIPTEN_RESULT_NOT_SUPPORTED => "Not supported", ffi::EMSCRIPTEN_RESULT_FAILED...
error_to_str
identifier_name
mod.rs
#![cfg(target_os = "emscripten")] use std::ffi::CString; use libc; use {Event, BuilderAttribs, CreationError, MouseCursor}; use Api; use PixelFormat; use GlContext; use std::collections::VecDeque; mod ffi; pub struct Window { context: ffi::EMSCRIPTEN_WEBGL_CONTEXT_HANDLE, } pub struct PollEventsIterator<'a> { ...
// TODO: emscripten_set_webglcontextrestored_callback Ok(Window { context: context }) } pub fn is_closed(&self) -> bool { use std::ptr; unsafe { ffi::emscripten_is_webgl_context_lost(ptr::null())!= 0 } } pub fn set_title(&self, _title: &str) { ...
random_line_split
mod.rs
#![cfg(target_os = "emscripten")] use std::ffi::CString; use libc; use {Event, BuilderAttribs, CreationError, MouseCursor}; use Api; use PixelFormat; use GlContext; use std::collections::VecDeque; mod ffi; pub struct Window { context: ffi::EMSCRIPTEN_WEBGL_CONTEXT_HANDLE, } pub struct PollEventsIterator<'a> { ...
pub fn get_position(&self) -> Option<(i32, i32)> { Some((0, 0)) } pub fn set_position(&self, _: i32, _: i32) { } pub fn get_inner_size(&self) -> Option<(u32, u32)> { unsafe { use std::{mem, ptr}; let mut width = mem::uninitialized(); let mut he...
{ }
identifier_body
fs.rs
46, 46, 0,..] => return None, _ => {} } Some(DirEntry { root: root.clone(), data: *wfd, }) } pub fn path(&self) -> PathBuf { self.root.join(&self.file_name()) } pub fn file_name(&self) -> OsString { let filename = super::trun...
{ unsafe extern "system" fn callback( _TotalFileSize: libc::LARGE_INTEGER, TotalBytesTransferred: libc::LARGE_INTEGER, _StreamSize: libc::LARGE_INTEGER, _StreamBytesTransferred: libc::LARGE_INTEGER, _dwStreamNumber: libc::DWORD, _dwCallbackReason: libc::DWORD, ...
identifier_body
fs.rs
} } impl DirEntry { fn new(root: &Arc<PathBuf>, wfd: &libc::WIN32_FIND_DATAW) -> Option<DirEntry> { match &wfd.cFileName[0..3] { // check for '.' and '..' [46, 0,..] | [46, 46, 0,..] => return None, _ => {} } Some(DirEntry { r...
Ok(attr) } } pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> { self.handle.read(buf) } pub fn write(&self, buf: &[u8]) -> io::Result<usize> { self.handle.write(buf) } pub fn flush(&self) -> io::Result<()> { Ok(()) } pub fn seek(&self, pos: See...
{ let mut b = [0; c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; if let Ok((_, buf)) = self.reparse_point(&mut b) { attr.reparse_tag = buf.ReparseTag; } }
conditional_block
fs.rs
(&self) -> libc::DWORD { self.flags_and_attributes.unwrap_or(libc::FILE_ATTRIBUTE_NORMAL) } } impl File { fn open_reparse_point(path: &Path, write: bool) -> io::Result<File> { let mut opts = OpenOptions::new(); opts.read(!write); opts.write(write); opts.flags_and_attribu...
} else { "SeBackupPrivilege".as_ref() }; let name = name.encode_wide().chain(Some(0)).collect::<Vec<_>>();
random_line_split
fs.rs
} } impl DirEntry { fn new(root: &Arc<PathBuf>, wfd: &libc::WIN32_FIND_DATAW) -> Option<DirEntry> { match &wfd.cFileName[0..3] { // check for '.' and '..' [46, 0,..] | [46, 46, 0,..] => return None, _ => {} } Some(DirEntry { r...
(&self) -> u64 { ((self.data.nFileSizeHigh as u64) << 32) | (self.data.nFileSizeLow as u64) } pub fn perm(&self) -> FilePermissions { FilePermissions { attrs: self.data.dwFileAttributes } } pub fn attrs(&self) -> u32 { self.data.dwFileAttributes as u32 } pub fn file_type(&self) ->...
size
identifier_name
reflector.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 syntax::ast::{ItemKind, MetaItem}; use syntax::codemap::Span; use syntax::ext::base::{Annotatable, ExtCtxt}; u...
impl_item.map(|it| push(Annotatable::Item(it))) }, // Or just call it on the first field (supertype). None => { let field_name = def.fields()[0].ident; let impl_item = quote_item!(cx, impl...
{ if let &Annotatable::Item(ref item) = annotatable { if let ItemKind::Struct(ref def, _) = item.node { let struct_name = item.ident; // This path has to be hardcoded, unfortunately, since we can't resolve paths at expansion time match def.fields().iter().find( ...
identifier_body
reflector.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 syntax::ast::{ItemKind, MetaItem}; use syntax::codemap::Span; use syntax::ext::base::{Annotatable, ExtCtxt}; u...
(cx: &mut ExtCtxt, span: Span, _: &MetaItem, annotatable: &Annotatable, push: &mut FnMut(Annotatable)) { if let &Annotatable::Item(ref item) = annotatable { if let ItemKind::Struct(ref def, _) = item.node { let struct_name = item.ident; // This path has to be ...
expand_reflector
identifier_name
reflector.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 syntax::ast::{ItemKind, MetaItem}; use syntax::codemap::Span; use syntax::ext::base::{Annotatable, ExtCtxt}; u...
}, // Or just call it on the first field (supertype). None => { let field_name = def.fields()[0].ident; let impl_item = quote_item!(cx, impl ::dom::bindings::reflector::Reflectable for $struct_name { ...
{ if let ItemKind::Struct(ref def, _) = item.node { let struct_name = item.ident; // This path has to be hardcoded, unfortunately, since we can't resolve paths at expansion time match def.fields().iter().find( |f| match_ty_unwrap(&*f.ty, &["dom", "bindings...
conditional_block
reflector.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 syntax::ast::{ItemKind, MetaItem}; use syntax::codemap::Span; use syntax::ext::base::{Annotatable, ExtCtxt}; u...
} } }
} else { cx.span_err(span, "#[dom_struct] seems to have been applied to a non-struct");
random_line_split
terminal.rs
//! Support for terminal symbols use crate::status::Result; use crate::status::Status;
pub enum Terminal { /// Literal string Literal(String), ///// Character matches a list of chars or a list of ranges //Match(MatchRules), ///// Indicates an error. ///// It will propagate an error while processing //Expected(String), /// Any char Dot, /// End Of File Eof, } p...
/// This is a simple expression with no dependencies with other rules #[derive(Debug, PartialEq, Clone)]
random_line_split
terminal.rs
//! Support for terminal symbols use crate::status::Result; use crate::status::Status; /// This is a simple expression with no dependencies with other rules #[derive(Debug, PartialEq, Clone)] pub enum Terminal { /// Literal string Literal(String), ///// Character matches a list of chars or a list of ranges...
fn parse_eof<'a>(status: Status<'a>) -> Result<'a> { match status.get_char() { Ok((st, _ch)) => Err(st.to_error("not end of file :-(")), Err(st) => Ok(st), } } fn parse_literal<'a>(mut status: Status<'a>, literal: &str) -> Result<'a> { for ch in literal.chars() { status = parse_ch...
{ match terminal { Terminal::Eof => parse_eof(status), Terminal::Literal(l) => parse_literal(status, l), Terminal::Dot => parse_dot(status), } }
identifier_body
terminal.rs
//! Support for terminal symbols use crate::status::Result; use crate::status::Status; /// This is a simple expression with no dependencies with other rules #[derive(Debug, PartialEq, Clone)] pub enum Terminal { /// Literal string Literal(String), ///// Character matches a list of chars or a list of ranges...
<'a>(mut status: Status<'a>, literal: &str) -> Result<'a> { for ch in literal.chars() { status = parse_char(status, ch).map_err(|st| st.to_error(&format!("'{}'", literal)))?; } Ok(status) } fn parse_dot<'a>(status: Status<'a>) -> Result<'a> { let (status, _ch) = status.get_char().map_err(|st| s...
parse_literal
identifier_name
mvp.rs
// taken from vecmath & cam (MIT) // https://github.com/PistonDevelopers/vecmath // https://github.com/PistonDevelopers/cam pub type Vector4 = [f32; 4]; pub type Matrix4 = [[f32; 4]; 4]; pub fn model_view_projection(model: Matrix4, view: Matrix4, projection: Matrix4) -> Matrix4 { col_mat4_mul(col_mat4_mul(project...
fn row_mat4_col(a: Matrix4, i: usize) -> Vector4 { [a[0][i], a[1][i], a[2][i], a[3][i]] }
{ row_mat4_col(a, i) }
identifier_body
mvp.rs
// taken from vecmath & cam (MIT) // https://github.com/PistonDevelopers/vecmath // https://github.com/PistonDevelopers/cam pub type Vector4 = [f32; 4]; pub type Matrix4 = [[f32; 4]; 4]; pub fn model_view_projection(model: Matrix4, view: Matrix4, projection: Matrix4) -> Matrix4 { col_mat4_mul(col_mat4_mul(project...
(a: Matrix4, b: Matrix4, i: usize) -> Vector4 { [ vec4_dot(col_mat4_row(a, 0), b[i]), vec4_dot(col_mat4_row(a, 1), b[i]), vec4_dot(col_mat4_row(a, 2), b[i]), vec4_dot(col_mat4_row(a, 3), b[i]), ] } fn vec4_dot(a: Vector4, b: Vector4) -> f32 { a[0] * b[0] + a[1] * b[1] + a[2]...
col_mat4_mul_col
identifier_name
mvp.rs
// taken from vecmath & cam (MIT) // https://github.com/PistonDevelopers/vecmath // https://github.com/PistonDevelopers/cam pub type Vector4 = [f32; 4]; pub type Matrix4 = [[f32; 4]; 4]; pub fn model_view_projection(model: Matrix4, view: Matrix4, projection: Matrix4) -> Matrix4 { col_mat4_mul(col_mat4_mul(project...
fn vec4_dot(a: Vector4, b: Vector4) -> f32 { a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3] } fn col_mat4_row(a: Matrix4, i: usize) -> Vector4 { row_mat4_col(a, i) } fn row_mat4_col(a: Matrix4, i: usize) -> Vector4 { [a[0][i], a[1][i], a[2][i], a[3][i]] }
] }
random_line_split
htmltablerowelement.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 cssparser::RGBA; use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; use d...
htmlelement: HTMLElement::new_inherited(local_name, prefix, document), cells: Default::default(), } } #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> Root<HTMLTableRowElement> { Node::re...
impl HTMLTableRowElement { fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLTableRowElement { HTMLTableRowElement {
random_line_split
htmltablerowelement.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 cssparser::RGBA; use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; use d...
#[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> Root<HTMLTableRowElement> { Node::reflect_node(box HTMLTableRowElement::new_inherited(local_name, prefix, document), document, ...
{ HTMLTableRowElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), cells: Default::default(), } }
identifier_body
htmltablerowelement.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 cssparser::RGBA; use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; use d...
; self.row_index(collection) } } pub trait HTMLTableRowElementLayoutHelpers { fn get_background_color(&self) -> Option<RGBA>; } #[allow(unsafe_code)] impl HTMLTableRowElementLayoutHelpers for LayoutJS<HTMLTableRowElement> { fn get_background_color(&self) -> Option<RGBA> { unsafe { ...
{ return -1; }
conditional_block
htmltablerowelement.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 cssparser::RGBA; use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; use d...
(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLTableRowElement { HTMLTableRowElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), cells: Default::default(), } } #[allow(unrooted_must_root)] ...
new_inherited
identifier_name
trace.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/. */ //! Utilities for tracing JS-managed values. //! //! The lifetime of DOM objects is managed by the SpiderMonkey Ga...
pub fn trace_object(tracer: *mut JSTracer, description: &str, obj: *mut JSObject) { unsafe { let name = CString::new(description).unwrap(); (*tracer).debugPrinter = None; (*tracer).debugPrintIndex =!0; (*tracer).debugPrintArg = name.as_ptr() as *const libc::c_void; debug!("tr...
trace_object(tracer, description, reflector.get_jsobject()) } /// Trace a `JSObject`.
random_line_split
trace.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/. */ //! Utilities for tracing JS-managed values. //! //! The lifetime of DOM objects is managed by the SpiderMonkey Ga...
} enum Void {} impl VecRootableType for Void { fn tag(_a: Option<Void>) -> CollectionType { unreachable!() } } impl Reflectable for Void { fn reflector<'a>(&'a self) -> &'a Reflector { unreachable!() } } /// A vector of items that are rooted for the lifetime /// of this struct #[allow(unrooted_must_root)] ...
{ CollectionType::JSObjects }
identifier_body
trace.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/. */ //! Utilities for tracing JS-managed values. //! //! The lifetime of DOM objects is managed by the SpiderMonkey Ga...
(&self, trc: *mut JSTracer) { if!self.is_null() { unsafe { (**self).trace(trc) } } } } impl<T: JSTraceable> JSTraceable for *mut T { fn trace(&self, trc: *mut JSTracer) { if!self.is_null() { unsafe { (**self).trace(trc)...
trace
identifier_name
trace.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/. */ //! Utilities for tracing JS-managed values. //! //! The lifetime of DOM objects is managed by the SpiderMonkey Ga...
unsafe { let name = CString::new(description).unwrap(); (*tracer).debugPrinter = None; (*tracer).debugPrintIndex =!0; (*tracer).debugPrintArg = name.as_ptr() as *const libc::c_void; debug!("tracing value {}", description); JS_CallTracer(tracer, val.to_gcthing(), val...
{ return; }
conditional_block
main.rs
#![cfg_attr(all(test, feature = "nightly"), feature(test))] // we only need test feature when testing #[macro_use] extern crate log; extern crate syntex_syntax; extern crate toml; extern crate env_logger; extern crate racer; #[cfg(not(test))] use racer::core; #[cfg(not(test))] use racer::util; #[cfg(not(test))] use...
(args: Vec<String>, linenum: usize, print_type: CompletePrinter) { // input: linenum, colnum, fname let tb = std::thread::Builder::new().name("searcher".to_string()); // PD: this probably sucks for performance, but lots of plugins // end up failin...
complete_by_line_coords
identifier_name
main.rs
#![cfg_attr(all(test, feature = "nightly"), feature(test))] // we only need test feature when testing #[macro_use] extern crate log; extern crate syntex_syntax; extern crate toml; extern crate env_logger; extern crate racer; #[cfg(not(test))] use racer::core; #[cfg(not(test))] use racer::util; #[cfg(not(test))] use...
match res.join() { Ok(_) => {}, Err(e) => { error!("Search thread paniced: {:?}", e); } } println!("END"); } #[cfg(not(test))] enum CompletePrinter { Normal, WithSnippets } #[cfg(not(test))] fn run_the_complete_fn(args: Vec<String>, linenum: usize, print_type:...
// end up failing and leaving tmp files around if racer crashes, // so catch the crash. let res = tb.spawn(move || { run_the_complete_fn(args, linenum, print_type); }).unwrap();
random_line_split
main.rs
#![cfg_attr(all(test, feature = "nightly"), feature(test))] // we only need test feature when testing #[macro_use] extern crate log; extern crate syntex_syntax; extern crate toml; extern crate env_logger; extern crate racer; #[cfg(not(test))] use racer::core; #[cfg(not(test))] use racer::util; #[cfg(not(test))] use...
#[cfg(not(test))] fn daemon() { use std::io; let mut input = String::new(); while let Ok(n) = io::stdin().read_line(&mut input) { if n == 0 { break; } let args: Vec<String> = input.split(" ").map(|s| s.trim().to_string()).collect(); run(args); i...
{ if let Ok(srcpaths) = std::env::var("RUST_SRC_PATH") { let v = srcpaths.split(PATH_SEP).collect::<Vec<_>>(); if !v.is_empty() { let f = Path::new(v[0]); if !path_exists(f) { println!("racer can't find the directory pointed to by the RUST_SRC_PATH variable \"...
identifier_body
expf32.rs
#![feature(core, core_intrinsics, core_float)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::expf32; use core::num::Float; use core::f32; // pub fn expf32(x: f32) -> f32; #[test] fn expf32_test1()
#[test] fn expf32_test2() { let x: f32 = f32::infinity(); let result: f32 = unsafe { expf32(x) }; assert_eq!(result, f32::infinity()); } #[test] fn expf32_test3() { let x: f32 = f32::neg_infinity(); let result: f32 = unsafe { expf32(x) }; assert_eq!(result, 0.0); } #[test] fn...
{ let x: f32 = f32::nan(); let result: f32 = unsafe { expf32(x) }; assert_eq!(result.is_nan(), true); }
identifier_body
expf32.rs
#![feature(core, core_intrinsics, core_float)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::expf32; use core::num::Float; use core::f32; // pub fn expf32(x: f32) -> f32; #[test] fn expf32_test1() { let x: f32 = f32::nan(); let result: f32 = unsafe { expf32(x) };
} #[test] fn expf32_test2() { let x: f32 = f32::infinity(); let result: f32 = unsafe { expf32(x) }; assert_eq!(result, f32::infinity()); } #[test] fn expf32_test3() { let x: f32 = f32::neg_infinity(); let result: f32 = unsafe { expf32(x) }; assert_eq!(result, 0.0); } #[test] ...
assert_eq!(result.is_nan(), true);
random_line_split
expf32.rs
#![feature(core, core_intrinsics, core_float)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::expf32; use core::num::Float; use core::f32; // pub fn expf32(x: f32) -> f32; #[test] fn expf32_test1() { let x: f32 = f32::nan(); let result: f32 = unsafe { expf32(x) }; ass...
() { let x: f32 = f32::infinity(); let result: f32 = unsafe { expf32(x) }; assert_eq!(result, f32::infinity()); } #[test] fn expf32_test3() { let x: f32 = f32::neg_infinity(); let result: f32 = unsafe { expf32(x) }; assert_eq!(result, 0.0); } #[test] fn expf32_test4() { let x: f32 = 1...
expf32_test2
identifier_name
WalkingState.rs
# Velocity # AngularVelocity # Relative Orientation # Relative Angular Velocity #---------------- # Heading -0.000295 # Root(pelvis) 0 0.943719 0 0.999705 0.001812 0.000000 -0.024203 0.085812 0.006683 0.046066 0.020659 0.025804 -0.043029 # pelvis_lowerback 0.999456 -0.008591 -0.000383 0.031834 0.0...
# order is: # Heading # Position # Orientation
random_line_split
vendor.rs
use crate::command_prelude::*; use cargo::ops; use std::path::PathBuf; pub fn cli() -> App { subcommand("vendor") .about("Vendor all dependencies for a project locally") .arg(opt("quiet", "No output printed to stdout").short("q")) .arg_manifest_path() .arg(Arg::with_name("path").help("W...
} else { None }; if let Some(flag) = crates_io_cargo_vendor_flag { return Err(anyhow::format_err!( "\ the crates.io `cargo vendor` command has now been merged into Cargo itself and does not support the flag `{}` currently; to continue using the flag you can execute `cargo-vendor ...
{ // We're doing the vendoring operation ourselves, so we don't actually want // to respect any of the `source` configuration in Cargo itself. That's // intended for other consumers of Cargo, but we want to go straight to the // source, e.g. crates.io, to fetch crates. if !args.is_present("respect-s...
identifier_body
vendor.rs
use crate::command_prelude::*; use cargo::ops; use std::path::PathBuf; pub fn cli() -> App { subcommand("vendor") .about("Vendor all dependencies for a project locally") .arg(opt("quiet", "No output printed to stdout").short("q")) .arg_manifest_path() .arg(Arg::with_name("path").help("W...
} else if args.is_present("only-git-deps") { Some("--only-git-deps") } else if args.is_present("disallow-duplicates") { Some("--disallow-duplicates") } else { None }; if let Some(flag) = crates_io_cargo_vendor_flag { return Err(anyhow::format_err!( "\ the ...
// that users currently using the flag aren't tripped up. let crates_io_cargo_vendor_flag = if args.is_present("no-merge-sources") { Some("--no-merge-sources") } else if args.is_present("relative-path") { Some("--relative-path")
random_line_split
vendor.rs
use crate::command_prelude::*; use cargo::ops; use std::path::PathBuf; pub fn cli() -> App { subcommand("vendor") .about("Vendor all dependencies for a project locally") .arg(opt("quiet", "No output printed to stdout").short("q")) .arg_manifest_path() .arg(Arg::with_name("path").help("W...
(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { // We're doing the vendoring operation ourselves, so we don't actually want // to respect any of the `source` configuration in Cargo itself. That's // intended for other consumers of Cargo, but we want to go straight to the // source, e.g. crat...
exec
identifier_name
borrowed-struct.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...
// lldb-command:print *unique_val_ref // lldb-check:[...]$4 = SomeStruct { x: 13, y: 26.5 } // lldb-command:print *unique_val_interior_ref_1 // lldb-check:[...]$5 = 13 // lldb-command:print *unique_val_interior_ref_2 // lldb-check:[...]$6 = 26.5 #![allow(unused_variable)] struct SomeStruct { x: int, y: f64...
// lldb-check:[...]$2 = 23.5 // lldb-command:print *ref_to_unnamed // lldb-check:[...]$3 = SomeStruct { x: 11, y: 24.5 }
random_line_split
borrowed-struct.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...
{ x: int, y: f64 } fn main() { let stack_val: SomeStruct = SomeStruct { x: 10, y: 23.5 }; let stack_val_ref: &SomeStruct = &stack_val; let stack_val_interior_ref_1: &int = &stack_val.x; let stack_val_interior_ref_2: &f64 = &stack_val.y; let ref_to_unnamed: &SomeStruct = &SomeStruct { x: 11...
SomeStruct
identifier_name
mem.rs
let request: ReporterRequest = message.to().unwrap(); system_reporter::collect_reports(request) }); mem_profiler_chan.send(ProfilerMsg::RegisterReporter("system".to_owned(), Reporter(system_reporter_sender))); mem_profile...
// Insert the path and size into the forest, adding any trees and nodes as necessary. fn insert(&mut self, path: &[String], size: usize) { let (head, tail) = path.split_first().unwrap(); // Get the right tree, creating it if necessary. if!self.trees.contains_key(head) { sel...
{ ReportsForest { trees: HashMap::new(), } }
identifier_body
mem.rs
reporters: HashMap<String, Reporter>, } const JEMALLOC_HEAP_ALLOCATED_STR: &'static str = "jemalloc-heap-allocated"; const SYSTEM_HEAP_ALLOCATED_STR: &'static str = "system-heap-allocated"; impl Profiler { pub fn create(period: Option<f64>) -> ProfilerChan { let (chan, port) = ipc::channel().unwrap();...
/// The port through which messages are received. pub port: IpcReceiver<ProfilerMsg>, /// Registered memory reporters.
random_line_split
mem.rs
let request: ReporterRequest = message.to().unwrap(); system_reporter::collect_reports(request) }); mem_profiler_chan.send(ProfilerMsg::RegisterReporter("system".to_owned(), Reporter(system_reporter_sender))); mem_profile...
(&mut self) { // Fill in sizes of interior nodes, and recursively sort the sub-trees. for (_, tree) in &mut self.trees { tree.compute_interior_node_sizes_and_sort(); } // Put the trees into a sorted vector. Primary sort: degenerate trees (those containing a // single...
print
identifier_name
expr-match-unique.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 ...
fn test_box() { let res: Box<_> = match true { true => { box 100 }, _ => panic!() }; assert_eq!(*res, 100); } pub fn main() { test_box(); }
random_line_split
expr-match-unique.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { test_box(); }
{ let res: Box<_> = match true { true => { box 100 }, _ => panic!() }; assert_eq!(*res, 100); }
identifier_body
expr-match-unique.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 ...
() { test_box(); }
main
identifier_name
callbacks.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
trait Object<T> { fn call(&self, args: T); } impl<UserData> Object<Args> for ::Callback<fn($($arg_ty),*, &UserData), UserData> { fn call(&self, ($($arg),*,): Args) { (self.f)($($arg),*, &self.data); } } pub fn set<UserData:'st...
random_line_split
callbacks.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
<'a>(window: &'a *mut ffi::GLFWwindow) -> &'a Sender<(f64, WindowEvent)> { mem::transmute(ffi::glfwGetWindowUserPointer(*window)) } macro_rules! window_callback( (fn $name:ident () => $event:ident) => ( pub extern "C" fn $name(window: *mut ffi::GLFWwindow) { unsafe { get_sender(&window).sen...
get_sender
identifier_name
callbacks.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
macro_rules! window_callback( (fn $name:ident () => $event:ident) => ( pub extern "C" fn $name(window: *mut ffi::GLFWwindow) { unsafe { get_sender(&window).send((ffi::glfwGetTime() as f64, $event)); } } ); (fn $name:ident ($($ext_arg:ident: $ext_arg_ty:ty),*) => $event:ident($...
{ mem::transmute(ffi::glfwGetWindowUserPointer(*window)) }
identifier_body
uv.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 ...
* This base module currently contains a historical, rust-based * implementation of a few libuv operations that hews closely to * the patterns of the libuv C-API. It was used, mostly, to explore * some implementation details and will most likely be deprecated * in the near future. * * The `ll` module contains low...
* These modules are seeing heavy work, currently, and the final * API layout should not be inferred from its current form. *
random_line_split
test.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{DEFAULT_BUILD_DIR, DEFAULT_PACKAGE_DIR, DEFAULT_SOURCE_DIR, DEFAULT_STORAGE_DIR}; use anyhow::anyhow; use move_coverage::coverage_map::{CoverageMap, ExecCoverageMapWithModules}; use move_lang::{ command_line::{read_bool_...
(path: &str) -> anyhow::Result<()> { let path = Path::new(path); if path.exists() { anyhow::bail!("{:#?} already exists. Remove {:#?} and re-run this command if creating it as a test directory was intentional.", path, path); } let format_src_dir = |dir| format!("{}/{}", DEFAULT_SOURCE_DIR, dir...
create_test_scaffold
identifier_name
test.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{DEFAULT_BUILD_DIR, DEFAULT_PACKAGE_DIR, DEFAULT_SOURCE_DIR, DEFAULT_STORAGE_DIR}; use anyhow::anyhow; use move_coverage::coverage_map::{CoverageMap, ExecCoverageMapWithModules}; use move_lang::{ command_line::{read_bool_...
} let mut output = "".to_string(); // for tracing file path: always use the absolute path so we do not need to worry about where // the VM is executed. let trace_file = env::current_dir()? .join(&build_output) .join(DEFAULT_TRACE_FILE); // Disable colors in error reporting from t...
random_line_split
test.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{DEFAULT_BUILD_DIR, DEFAULT_PACKAGE_DIR, DEFAULT_SOURCE_DIR, DEFAULT_STORAGE_DIR}; use anyhow::anyhow; use move_coverage::coverage_map::{CoverageMap, ExecCoverageMapWithModules}; use move_lang::{ command_line::{read_bool_...
.join(DEFAULT_TRACE_FILE); // Disable colors in error reporting from the Move compiler env::set_var(COLOR_MODE_ENV_VAR, "NONE"); for args_line in args_file { let args_line = args_line?; if args_line.starts_with('#') { // allow comments in args.txt continue; ...
{ let args_file = io::BufReader::new(File::open(args_path)?).lines(); // path where we will run the binary let exe_dir = args_path.parent().unwrap(); let cli_binary_path = Path::new(cli_binary).canonicalize()?; let storage_dir = Path::new(exe_dir).join(DEFAULT_STORAGE_DIR); let build_output = Pa...
identifier_body
test.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{DEFAULT_BUILD_DIR, DEFAULT_PACKAGE_DIR, DEFAULT_SOURCE_DIR, DEFAULT_STORAGE_DIR}; use anyhow::anyhow; use move_coverage::coverage_map::{CoverageMap, ExecCoverageMapWithModules}; use move_lang::{ command_line::{read_bool_...
} } ret } fn collect_coverage( trace_file: &Path, build_dir: &Path, storage_dir: &Path, ) -> anyhow::Result<ExecCoverageMapWithModules> { fn find_compiled_move_filenames(path: &Path) -> anyhow::Result<Vec<String>> { if path.exists() { move_lang::find_filenames(&[pat...
{ ret.push_str("\x1B[91m"); ret.push_str(x); ret.push_str("\x1B[0m"); ret.push('\n'); }
conditional_block
error.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the ...
} ProcessExitFailure { description("Process did not exit properly") display("Process did not exit properly") } InstantiateError { description("Instantation error") display("Instantation error") } } }
description("No editor set") display("No editor set")
random_line_split
p041.rs
//! [Problem 41](https://projecteuler.net/problem=41) solver. #![warn(bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results)] #[macro_use(problem)] extern crate common; extern crate iter; extern crate integer; extern crate prime; use iter::Permutations; ...
} unreachable!() } fn solve() -> String { compute().to_string() } problem!("7652413", solve);
{ return n }
conditional_block
p041.rs
//! [Problem 41](https://projecteuler.net/problem=41) solver. #![warn(bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results)] #[macro_use(problem)] extern crate common; extern crate iter; extern crate integer; extern crate prime; use iter::Permutations; ...
() -> String { compute().to_string() } problem!("7652413", solve);
solve
identifier_name