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
quality_counts.rs
use crate::trust_seq::group::BaseGroup; use std::cmp; use std::f64; pub struct QualityCounts { pub counts: Vec<QualityCount>, } impl QualityCounts { pub fn
() -> QualityCounts { return QualityCounts { counts: Vec::new() }; } pub fn ensure_size(&mut self, len: usize) { if self.counts.len() < len { self.counts.resize(len, QualityCount::new()); } } pub fn add_value(&mut self, idx: usize, ch: u8) { self.ensure_size(i...
new
identifier_name
p114.rs
//! [Problem 114](https://projecteuler.net/problem=114) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use std::collections::HashMap; fn
((n, m): (u32, u32), map: &mut HashMap<(u32, u32), u64>) -> u64 { if let Some(&x) = map.get(&(n, m)) { return x; } if n < m { let _ = map.insert((n, m), 1); return 1; } let mut sum = 0; for len in m..(n + 1) { // most left red block length for i in 0..(...
get_cnt
identifier_name
p114.rs
//! [Problem 114](https://projecteuler.net/problem=114) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use std::collections::HashMap; fn get_cnt((n, m): (u32, u32), map: &mut HashMap<(u32, u32), u64>) -> u64 { if le...
let mut sum = 0; for len in m..(n + 1) { // most left red block length for i in 0..(n - len + 1) { // most left red block position if n > len + i { sum += get_cnt((n - (len + i) - 1, m), map); // red block and black block } else { ...
{ let _ = map.insert((n, m), 1); return 1; }
conditional_block
p114.rs
//! [Problem 114](https://projecteuler.net/problem=114) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use std::collections::HashMap; fn get_cnt((n, m): (u32, u32), map: &mut HashMap<(u32, u32), u64>) -> u64 { if le...
} fn solve() -> String { let mut map = HashMap::new(); get_cnt((50, 3), &mut map).to_string() } common::problem!("16475640049", solve); #[cfg(test)] mod tests { use super::get_cnt; use std::collections::HashMap; #[test] fn small_len() { let mut map = HashMap::new(); assert_eq...
random_line_split
p114.rs
//! [Problem 114](https://projecteuler.net/problem=114) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use std::collections::HashMap; fn get_cnt((n, m): (u32, u32), map: &mut HashMap<(u32, u32), u64>) -> u64
} } } sum += 1; // all black block let _ = map.insert((n, m), sum); sum } fn solve() -> String { let mut map = HashMap::new(); get_cnt((50, 3), &mut map).to_string() } common::problem!("16475640049", solve); #[cfg(test)] mod tests { use super::get_cnt; use std::c...
{ if let Some(&x) = map.get(&(n, m)) { return x; } if n < m { let _ = map.insert((n, m), 1); return 1; } let mut sum = 0; for len in m..(n + 1) { // most left red block length for i in 0..(n - len + 1) { // most left red block position ...
identifier_body
glib.rs
// Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co // // This file is part of cancer. // // cancer 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 // (a...
pub data: *mut c_void, pub next: *mut GList, pub prev: *mut GList, } extern "C" { pub fn g_list_free(ptr: *mut GList); pub fn g_object_unref(ptr: *mut c_void); pub fn g_object_ref(ptr: *mut c_void) -> *mut c_void; }
ist {
identifier_name
glib.rs
// Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co // // This file is part of cancer. // // cancer 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 // (a...
pub fn g_object_ref(ptr: *mut c_void) -> *mut c_void; }
pub fn g_list_free(ptr: *mut GList); pub fn g_object_unref(ptr: *mut c_void);
random_line_split
htmlmapelement.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::HTMLMapElementBinding; use dom::bindings::codegen::InheritTypes::HTMLMapElem...
prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLMapElement { HTMLMapElement { htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLMapElement, localName, prefix, document) } } #[allow(unrooted_must_root)] pub fn ne...
impl HTMLMapElement { fn new_inherited(localName: DOMString,
random_line_split
htmlmapelement.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::HTMLMapElementBinding; use dom::bindings::codegen::InheritTypes::HTMLMapElem...
(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLMapElement { HTMLMapElement { htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLMapElement, localName, prefix, document) } } #[allow(unrooted_mu...
new_inherited
identifier_name
font.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 app_units::Au; use font::{FontHandleMethods, FontMetrics, FontTableMethods}; use font::{FontTableTag, Fraction...
// TODO(pcwalton): Implement this. font_stretch::T::normal } fn glyph_index(&self, codepoint: char) -> Option<GlyphId> { assert!(!self.face.is_null()); unsafe { let idx = FT_Get_Char_Index(self.face, codepoint as FT_ULong); if idx!= 0 as FT_UInt { ...
} } } } fn stretchiness(&self) -> font_stretch::T {
random_line_split
font.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 app_units::Au; use font::{FontHandleMethods, FontMetrics, FontTableMethods}; use font::{FontTableTag, Fraction...
let mut strikeout_size = Au(0); let mut strikeout_offset = Au(0); let mut x_height = Au(0); unsafe { let os2 = FT_Get_Sfnt_Table(face, FT_Sfnt_Tag::FT_SFNT_OS2) as *mut TT_OS2; let valid =!os2.is_null() && (*os2).version!= 0xffff; if valid { ...
{ /* TODO(Issue #76): complete me */ let face = self.face_rec_mut(); let underline_size = self.font_units_to_au(face.underline_thickness as f64); let underline_offset = self.font_units_to_au(face.underline_position as f64); let em_size = self.font_units_to_au(face.units_per_EM a...
identifier_body
font.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 app_units::Au; use font::{FontHandleMethods, FontMetrics, FontTableMethods}; use font::{FontTableTag, Fraction...
(&self, value: f64) -> Au { let face = self.face_rec_mut(); // face.size is a *c_void in the bindings, presumably to avoid // recursive structural types let size: &FT_SizeRec = unsafe { mem::transmute(&(*face.size)) }; let metrics: &FT_Size_Metrics = &(*size).metrics; l...
font_units_to_au
identifier_name
unix.rs
// Filebuffer -- Fast and simple file reading // Copyright 2016 Ruud van Asseldonk // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // A copy of the License has been included in the root of the repository. //! This mod contains th...
} /// Requests the kernel to make the specified range of bytes resident in physical memory. `buffer` /// must be page-aligned. pub fn prefetch(buffer: *const u8, length: usize) { let result = unsafe { libc::madvise(buffer as *mut libc::c_void, length, libc::MADV_WILLNEED) }; // Any returned error...
{ use std::thread; let result = unsafe { // Note: the libc on BSD descendants uses a signed char for residency_char while // glibc uses an unsigned one, which is why we use an type-inferred cast here. let residency_char = residency.as_mut_ptr() as *mut _; assert_eq!(1, mem::size...
identifier_body
unix.rs
// Filebuffer -- Fast and simple file reading // Copyright 2016 Ruud van Asseldonk // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // A copy of the License has been included in the root of the repository. //! This mod contains th...
assert_eq!(1, mem::size_of_val(&*residency_char)); libc::mincore(buffer as *mut libc::c_void, length, residency_char) }; // Any error code except EAGAIN indicates a programming error. assert!(result == libc::EAGAIN || result == 0); // In the rare occasion that the kernel is busy, yield...
let residency_char = residency.as_mut_ptr() as *mut _;
random_line_split
unix.rs
// Filebuffer -- Fast and simple file reading // Copyright 2016 Ruud van Asseldonk // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // A copy of the License has been included in the root of the repository. //! This mod contains th...
(buffer: *const u8, length: usize, residency: &mut [bool]) { use std::thread; let result = unsafe { // Note: the libc on BSD descendants uses a signed char for residency_char while // glibc uses an unsigned one, which is why we use an type-inferred cast here. let residency_char = reside...
get_resident
identifier_name
unix.rs
// Filebuffer -- Fast and simple file reading // Copyright 2016 Ruud van Asseldonk // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // A copy of the License has been included in the root of the repository. //! This mod contains th...
// Don't try to map anything if the file is empty. if length == 0 { return Ok((ptr::null(), 0, PlatformData)); } let result = unsafe { libc::mmap(ptr::null_mut(), length as usize, libc::PROT_READ, libc::MAP_PRIVATE, fd, 0) }; if result == libc::MAP_FAILED { Err(io::Er...
{ return Err(io::Error::new(io::ErrorKind::Other, "file is larger than address space")); }
conditional_block
generic-functions-nested.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...
<TA: Clone>(a: TA) { inner(a.clone(), 1); inner(a.clone(), 2.5); fn inner<TX, TY>(x: TX, y: TY) { zzz(); } } fn main() { outer(-1); outer(-2.5); } fn zzz() {()}
outer
identifier_name
generic-functions-nested.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
// ignore-android: FIXME(#10381) // compile-flags:-g // gdb-command:rbreak zzz // gdb-command:run // gdb-command:finish // gdb-command:print x // gdb-check:$1 = -1 // gdb-command:print y // gdb-check:$2 = 1 // gdb-command:continue // gdb-command:finish // gdb-command:print x // gdb-check:$3 = -1 // gdb-command:print...
// <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.
random_line_split
generic-functions-nested.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...
} fn main() { outer(-1); outer(-2.5); } fn zzz() {()}
{ zzz(); }
identifier_body
mod.rs
pub mod standard_arena; pub mod to_ui; use db::enums; use player::Player; use std::collections::HashMap; /// The Arena struct holds the weather and the type of the arena aswell as the references at the /// two players #[derive(Debug)] pub struct Arena<'a> { default_effect: enums::Types, current_effect: (enums...
else { self.current_weather = (self.default_weather, 0); } } }
{ self.current_weather.1 += 1; }
conditional_block
mod.rs
pub mod standard_arena; pub mod to_ui; use db::enums; use player::Player; use std::collections::HashMap; /// The Arena struct holds the weather and the type of the arena aswell as the references at the /// two players #[derive(Debug)] pub struct Arena<'a> { default_effect: enums::Types, current_effect: (enums...
(&mut self, new: enums::Weather) { self.current_weather = (new, 0); } // Other Methods // /// Checks if field effects and weather are still valid. /// Field effects are compared with their maximum lifetime. If the effects reached it their /// dropped out of the HashMap /// Weather la...
set_current_weather
identifier_name
mod.rs
pub mod standard_arena; pub mod to_ui; use db::enums; use player::Player; use std::collections::HashMap; /// The Arena struct holds the weather and the type of the arena aswell as the references at the /// two players #[derive(Debug)] pub struct Arena<'a> { default_effect: enums::Types, current_effect: (enums...
impl<'a> Arena<'a> { /// Creates a new arena with a the two players, the default effect and the default weather pub fn new(i_player_1: &'a mut Player, i_player_2: &'a mut Player, i_effect: enums::Types, i_weather: enums::Weather) -> Self { Are...
field_effects: HashMap<enums::FieldEffects, u8>, player_1: &'a mut Player, player_2: &'a mut Player, }
random_line_split
powerpc64_unknown_linux_musl.rs
// Copyright 2018 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 ...
() -> TargetResult { let mut base = super::linux_musl_base::opts(); base.cpu = "ppc64".to_string(); base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string()); base.max_atomic_width = Some(64); Ok(Target { llvm_target: "powerpc64-unknown-linux-musl".to_string(), ...
target
identifier_name
powerpc64_unknown_linux_musl.rs
// Copyright 2018 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 ...
options: base, }) }
arch: "powerpc64".to_string(), target_os: "linux".to_string(), target_env: "musl".to_string(), target_vendor: "unknown".to_string(), linker_flavor: LinkerFlavor::Gcc,
random_line_split
powerpc64_unknown_linux_musl.rs
// Copyright 2018 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 mut base = super::linux_musl_base::opts(); base.cpu = "ppc64".to_string(); base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string()); base.max_atomic_width = Some(64); Ok(Target { llvm_target: "powerpc64-unknown-linux-musl".to_string(), target_endian: "b...
identifier_body
logging.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use context::{CoreContext, PerfCounters}; use futures_stats::{FutureStats, StreamStats}; use hgproto::GettreepackArgs; use iterhelpers::chu...
} } fn debug_format_directory<T: AsRef<[u8]>>(directory: &T) -> String { String::from_utf8_lossy(&hgproto::batch::escape(directory)).to_string() } pub fn debug_format_manifest(node: &HgManifestId) -> String { format!("{}", node) } pub fn debug_format_path(path: &Option<MPath>) -> String { match path ...
for (k, v) in self.extra.into_iter() { scuba.add(k, v); } scuba.log_with_msg("Command processed", None);
random_line_split
logging.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use context::{CoreContext, PerfCounters}; use futures_stats::{FutureStats, StreamStats}; use hgproto::GettreepackArgs; use iterhelpers::chu...
} /// Logs wireproto requests both to scuba. /// Scuba logs are used for analysis of performance. #[must_use = "A CommandLogger does not do anything if you don't use it"] pub struct CommandLogger { inner: ScubaOnlyCommandLogger, } impl CommandLogger { pub fn new(ctx: CoreContext, request_perf_counters: Arc<P...
{ Self::Stream(stats) }
identifier_body
logging.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use context::{CoreContext, PerfCounters}; use futures_stats::{FutureStats, StreamStats}; use hgproto::GettreepackArgs; use iterhelpers::chu...
(stats: &'a FutureStats) -> Self { Self::Future(stats) } } impl<'a> From<&'a StreamStats> for CommandStats<'a> { fn from(stats: &'a StreamStats) -> Self { Self::Stream(stats) } } /// Logs wireproto requests both to scuba. /// Scuba logs are used for analysis of performance. #[must_use = "A...
from
identifier_name
logging.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use context::{CoreContext, PerfCounters}; use futures_stats::{FutureStats, StreamStats}; use hgproto::GettreepackArgs; use iterhelpers::chu...
} } #[must_use = "A CommandLogger does not do anything if you don't use it"] pub struct ScubaOnlyCommandLogger { ctx: CoreContext, request_perf_counters: Arc<PerfCounters>, extra: HashMap<String, ScubaValue>, } impl ScubaOnlyCommandLogger { fn new(ctx: CoreContext, request_perf_counters: Arc<Perf...
{ let limit = ::std::cmp::min(args.len(), 1000); self.add_scuba_extra(k, &args[..limit]); }
conditional_block
traversal.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/. */ //! Traversing the DOM tree; the bloom filter. use animation; use context::{LocalStyleContext, SharedStyleContext...
, None => { relations = StyleRelations::empty(); if node.has_changed() { node.set_restyle_damage(N::ConcreteRestyleDamage::rebuild_and_reflow()) } None }, ...
{ if opts::get().style_sharing_stats { STYLE_SHARING_CACHE_MISSES.fetch_add(1, Ordering::Relaxed); } // Perform the CSS selector matching. let stylist = &context.shared_context().stylist; ...
conditional_block
traversal.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/. */ //! Traversing the DOM tree; the bloom filter. use animation; use context::{LocalStyleContext, SharedStyleContext...
/// Do an action over the child before pushing him to the work queue. /// /// By default, propagate the IS_DIRTY flag down the tree. #[allow(unsafe_code)] fn pre_process_child_hook(&self, parent: N, kid: N) { // NOTE: At this point is completely safe to modify either the parent or ...
{ opts::get().nonincremental_layout || node.is_dirty() || node.has_dirty_descendants() }
identifier_body
traversal.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/. */ //! Traversing the DOM tree; the bloom filter. use animation; use context::{LocalStyleContext, SharedStyleContext...
} StyleSharingResult::StyleWasShared(index, damage, cached_restyle_result) => { restyle_result = cached_restyle_result; if opts::get().style_sharing_stats { STYLE_SHARING_CACHE_HITS.fetch_add(1, Ordering::Relaxed); } ...
// Add ourselves to the LRU cache. if let Some(element) = shareable_element { style_sharing_candidate_cache.insert_if_possible(&element, relations); }
random_line_split
traversal.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/. */ //! Traversing the DOM tree; the bloom filter. use animation; use context::{LocalStyleContext, SharedStyleContext...
(relations: &StyleRelations) -> bool { use selectors::matching::*; !relations.intersects(AFFECTED_BY_ID_SELECTOR | AFFECTED_BY_PSEUDO_ELEMENTS | AFFECTED_BY_STATE | AFFECTED_BY_NON_COMMON_STYLE_AFFECTING_ATTRIBUTE_SELECTOR | AFFECTED_B...
relations_are_shareable
identifier_name
ffi.rs
// Copyright 2017 The Bazel Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by appl...
{ pub rows: size_t, pub cols: size_t, pub data: *mut u64, } // #[link(name = "native_matrix")] // Don't need this, BUILD file manages linking already. extern "C" { pub fn matrix_new(rows: size_t, cols: size_t, data: *const u64) -> *mut Matrix; pub fn matrix_at(matrix: *const Matrix, row: size_t, c...
Matrix
identifier_name
ffi.rs
// Copyright 2017 The Bazel Authors. All rights reserved.
// 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 // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WAR...
// // Licensed under the Apache License, Version 2.0 (the "License");
random_line_split
new_v1_formatted.rs
#![feature(core, collections)] extern crate core; extern crate collections; #[cfg(test)] mod tests { use core::fmt::write; use core::fmt::Result; use core::fmt::Error; use core::fmt::Write; use core::fmt::ArgumentV1; use core::fmt::Arguments; use core::fmt::Display; use collections::ve...
// fn write_fmt(&mut self, args: Arguments) -> Result { // // This Adapter is needed to allow `self` (of type `&mut // // Self`) to be cast to a Write (below) without // // requiring a `Sized` bound. // struct Adapter<'a,T:?Sized +'a>(&'a mut T); // // impl<'a, T:?Sized> Write for Adapter<'a...
// fn write_char(&mut self, c: char) -> Result { // let mut utf_8 = [0u8; 4]; // let bytes_written = c.encode_utf8(&mut utf_8).unwrap_or(0); // self.write_str(unsafe { mem::transmute(&utf_8[..bytes_written]) }) // }
random_line_split
new_v1_formatted.rs
#![feature(core, collections)] extern crate core; extern crate collections; #[cfg(test)] mod tests { use core::fmt::write; use core::fmt::Result; use core::fmt::Error; use core::fmt::Write; use core::fmt::ArgumentV1; use core::fmt::Arguments; use core::fmt::Display; use collections::ve...
(&mut self, s: &str) -> Result { for b in s.bytes() { self.buf.push(b); } Ok(()) } // fn write_char(&mut self, c: char) -> Result { // let mut utf_8 = [0u8; 4]; // let bytes_written = c.encode_utf8(&mut utf_8).unwrap_or(0); // self.write_str(unsafe { mem::transmute(&utf_8[..bytes_writ...
write_str
identifier_name
proposed.rs
// // use std::any::Any; // // pub struct ActorWrapper { // // pass_message: Box<Fn(Box<Any>)>, // // } // // pub trait Receive { // // fn receive(&self, message: Box<Any>); // // } // // impl ActorWrapper { // // pub fn new<A: Any + Receive>(actor: A) -> ActorWrapper { // // ActorWrapper { // //...
// // // // // // // // // // // fn main() { // struct MyMessage { // content: String // } // impl Message for MyMessage { // fn content(&self) -> String { // return self.content.clone(); // } // } // trait Message { // fn content(&self) -> ...
random_line_split
composite.rs
#[macro_export] macro_rules! composite { ( $( $arg:expr ),+ ) => { { use $crate::component::{Component, SubComponent}; use $crate::Error; use ::futures::{Poll, Async}; struct CompositeComponent { components: Vec<SubComponent>, } ...
fn poll(&mut self) -> Poll<Option<String>, Error> { let mut do_update = false; for stream in &mut self.streams { match stream.poll() { Ok(Async::Ready(Some((id, update)))) => { do...
type Error = Error;
random_line_split
extern-types-not-sync-send.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { assert_sync::<A>(); //~^ ERROR `A` cannot be shared between threads safely [E0277] assert_send::<A>(); //~^ ERROR `A` cannot be sent between threads safely [E0277] }
{ }
identifier_body
extern-types-not-sync-send.rs
// Copyright 2017 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 ...
extern { type A; } fn assert_sync<T:?Sized + Sync>() { } fn assert_send<T:?Sized + Send>() { } fn main() { assert_sync::<A>(); //~^ ERROR `A` cannot be shared between threads safely [E0277] assert_send::<A>(); //~^ ERROR `A` cannot be sent between threads safely [E0277] }
random_line_split
extern-types-not-sync-send.rs
// Copyright 2017 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:?Sized + Sync>() { } fn assert_send<T:?Sized + Send>() { } fn main() { assert_sync::<A>(); //~^ ERROR `A` cannot be shared between threads safely [E0277] assert_send::<A>(); //~^ ERROR `A` cannot be sent between threads safely [E0277] }
assert_sync
identifier_name
update_device.rs
//! `PUT /_matrix/client/*/devices/{deviceId}` pub mod v3 { //! `/v3/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#put_matrixclientv3devicesdeviceid use ruma_common::{api::ruma_api, DeviceId}; ruma_api! { metadata: { description: "Update metadata f...
() -> Self { Self {} } } }
new
identifier_name
update_device.rs
//! `PUT /_matrix/client/*/devices/{deviceId}` pub mod v3 { //! `/v3/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#put_matrixclientv3devicesdeviceid use ruma_common::{api::ruma_api, DeviceId}; ruma_api! { metadata: { description: "Update metadata f...
} }
{ Self {} }
identifier_body
update_device.rs
//! `PUT /_matrix/client/*/devices/{deviceId}` pub mod v3 { //! `/v3/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#put_matrixclientv3devicesdeviceid use ruma_common::{api::ruma_api, DeviceId}; ruma_api! { metadata: { description: "Update metadata f...
}
random_line_split
url.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::cell::DOMRefCell; use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use dom::bind...
(&self, value: USVString) -> ErrorResult { match ServoUrl::parse(&value.0) { Ok(url) => { *self.url.borrow_mut() = url; self.search_params.set(None); // To be re-initialized in the SearchParams getter. Ok(()) }, Err(error) => {...
SetHref
identifier_name
url.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::cell::DOMRefCell; use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use dom::bind...
} impl URL { // https://url.spec.whatwg.org/#constructors pub fn Constructor(global: &GlobalScope, url: USVString, base: Option<USVString>) -> Fallible<Root<URL>> { let parsed_base = match base { None => { // Step 1. ...
{ if let Some(ref mut url) = self.url.borrow_mut().as_mut_url() { url.query_pairs_mut().clear().extend_pairs(pairs); } }
identifier_body
url.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::cell::DOMRefCell; use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use dom::bind...
impl URL { fn new_inherited(url: ServoUrl) -> URL { URL { reflector_: Reflector::new(), url: DOMRefCell::new(url), search_params: Default::default(), } } pub fn new(global: &GlobalScope, url: ServoUrl) -> Root<URL> { reflect_dom_object(box URL::ne...
random_line_split
lib.rs
use std::iter::range_step; pub fn p1() -> u32 { range(0, 1_000).fold(0, |a, b| if b % 3 == 0 || b % 5 == 0 { a + b } else { a }) } pub fn p2() -> u32 { fn
(a: u32, b: u32) -> u32 { let c = a + b; if c > 4_000_000 { return 0; } let f = fib(b, c); if c % 2 == 0 { f + c } else { f } } fib(0, 1) } pub fn p3() -> u64 { let num = 600_851_475_143u64; let sqrt = (num as f64).sqrt(); let size = sqrt as uint; let mut sieve = ...
fib
identifier_name
lib.rs
use std::iter::range_step; pub fn p1() -> u32 { range(0, 1_000).fold(0, |a, b| if b % 3 == 0 || b % 5 == 0 { a + b } else { a }) } pub fn p2() -> u32 { fn fib(a: u32, b: u32) -> u32
fib(0, 1) } pub fn p3() -> u64 { let num = 600_851_475_143u64; let sqrt = (num as f64).sqrt(); let size = sqrt as uint; let mut sieve = Vec::from_elem(size, true); *sieve.get_mut(0) = false; *sieve.get_mut(1) = false; let sqrtsqrt = sqrt.sqrt() as uint; for i in range(2, sqrtsqrt) {...
{ let c = a + b; if c > 4_000_000 { return 0; } let f = fib(b, c); if c % 2 == 0 { f + c } else { f } }
identifier_body
lib.rs
use std::iter::range_step; pub fn p1() -> u32 { range(0, 1_000).fold(0, |a, b| if b % 3 == 0 || b % 5 == 0 { a + b } else { a }) } pub fn p2() -> u32 { fn fib(a: u32, b: u32) -> u32 { let c = a + b; if c > 4_000_000 { return 0; } let f = fib(b, c); if c % 2 == 0 { f + c } else {...
if cur == val { return val } cur = cur / val } num }
if !sieve[i] { continue } let val = i as u64; if cur % val != 0 { continue }
random_line_split
lib.rs
use std::iter::range_step; pub fn p1() -> u32 { range(0, 1_000).fold(0, |a, b| if b % 3 == 0 || b % 5 == 0 { a + b } else { a }) } pub fn p2() -> u32 { fn fib(a: u32, b: u32) -> u32 { let c = a + b; if c > 4_000_000 { return 0; } let f = fib(b, c); if c % 2 == 0 { f + c } else
} fib(0, 1) } pub fn p3() -> u64 { let num = 600_851_475_143u64; let sqrt = (num as f64).sqrt(); let size = sqrt as uint; let mut sieve = Vec::from_elem(size, true); *sieve.get_mut(0) = false; *sieve.get_mut(1) = false; let sqrtsqrt = sqrt.sqrt() as uint; for i in range(2, sqrts...
{ f }
conditional_block
kernel.rs
// // Copyright (C) 2015 // Gerald Van Baren, <gvb@unssw.com> // SPDX-License-Identifier: LGPL-3.0 // #![feature(no_std)] #![feature(core)] #![feature(asm)] #![no_std] #![crate_type="staticlib"] #![feature(core_intrinsics)] // rustc -C opt-level=2 -Z no-landing-pads --target arm-none-eabi -g --emit obj -L libcore-arm...
// our breakpoing is one. unsafe { intrinsics::breakpoint(); } loop {} } #[no_mangle] pub unsafe fn __aeabi_unwind_cpp_pr0() -> () { intrinsics::breakpoint(); } #[no_mangle] pub unsafe fn __aeabi_unwind_cpp_pr1() -> () { intrinsics::breakpoint(); } /**********************************...
#[lang="panic_fmt"] pub fn panic_fmt(_fmt: &core::fmt::Arguments, _file_line: &(&'static str, usize)) -> ! { // The rust compiler wants an infinite loop, but doesn't realize
random_line_split
kernel.rs
// // Copyright (C) 2015 // Gerald Van Baren, <gvb@unssw.com> // SPDX-License-Identifier: LGPL-3.0 // #![feature(no_std)] #![feature(core)] #![feature(asm)] #![no_std] #![crate_type="staticlib"] #![feature(core_intrinsics)] // rustc -C opt-level=2 -Z no-landing-pads --target arm-none-eabi -g --emit obj -L libcore-arm...
() { unsafe { intrinsics::breakpoint(); } } #[lang="eh_personality"] extern fn eh_personality() { unsafe { intrinsics::breakpoint(); } } #[lang="panic_fmt"] pub fn panic_fmt(_fmt: &core::fmt::Arguments, _file_line: &(&'static str, usize)) ->! { // The rust compiler wants an infinit...
stack_exhausted
identifier_name
kernel.rs
// // Copyright (C) 2015 // Gerald Van Baren, <gvb@unssw.com> // SPDX-License-Identifier: LGPL-3.0 // #![feature(no_std)] #![feature(core)] #![feature(asm)] #![no_std] #![crate_type="staticlib"] #![feature(core_intrinsics)] // rustc -C opt-level=2 -Z no-landing-pads --target arm-none-eabi -g --emit obj -L libcore-arm...
#[lang="eh_personality"] extern fn eh_personality() { unsafe { intrinsics::breakpoint(); } } #[lang="panic_fmt"] pub fn panic_fmt(_fmt: &core::fmt::Arguments, _file_line: &(&'static str, usize)) ->! { // The rust compiler wants an infinite loop, but doesn't realize // our breakpoing is one. ...
{ unsafe { intrinsics::breakpoint(); } }
identifier_body
kernel.rs
// // Copyright (C) 2015 // Gerald Van Baren, <gvb@unssw.com> // SPDX-License-Identifier: LGPL-3.0 // #![feature(no_std)] #![feature(core)] #![feature(asm)] #![no_std] #![crate_type="staticlib"] #![feature(core_intrinsics)] // rustc -C opt-level=2 -Z no-landing-pads --target arm-none-eabi -g --emit obj -L libcore-arm...
// Flash at 1Hz if timer.counter() as u32 - counter > (1000000 / 2) { gpio.set_to(STATUS_LED, flash); flash =!flash; // The obvious thing is to read the timer.counter(), but that // would result in clock drift. counter = counter + (1000000 / 2...
{ uart0.putc(uart0.getc()); }
conditional_block
match-pattern-lit.rs
// 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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except accordin...
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
random_line_split
match-pattern-lit.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 ...
(f: isize) -> isize { match f { 10 => { println!("case 10"); return 20; } 11 => { println!("case 11"); return 22; } _ => panic!("the impossible happened") } } pub fn main() { assert_eq!(altlit(10), 20); assert_eq!(altlit(11), 22); }
altlit
identifier_name
match-pattern-lit.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() { assert_eq!(altlit(10), 20); assert_eq!(altlit(11), 22); }
{ match f { 10 => { println!("case 10"); return 20; } 11 => { println!("case 11"); return 22; } _ => panic!("the impossible happened") } }
identifier_body
prompts.rs
/// Functionality for prompting the user to make a choice or type some text. use std::io::{self, Write}; use std::cmp; use std::num; use rand::{self, Rng}; use std::fmt; use std::error; use std::rc::Rc; use std::cell::RefCell; /// Possible errors when prompting. #[derive(Debug)] pub enum PromptError { Io(io::Erro...
// coin flip rand::thread_rng().gen_range(0, 2) == 0 } /// Prompt the user for a choice from the given list of displayable items. /// Return Ok(item index) if the chosen **item** was successfully picked, /// otherwise return Err(PromptError). pub fn choose<T: fmt::Display>(a: &[T]) -> Result<usize, PromptError...
Err(PromptError::Io(e)) => println!("{}", e), Err(_) => println!("Please make a valid answer."), } numprompts += 1; }
random_line_split
prompts.rs
/// Functionality for prompting the user to make a choice or type some text. use std::io::{self, Write}; use std::cmp; use std::num; use rand::{self, Rng}; use std::fmt; use std::error; use std::rc::Rc; use std::cell::RefCell; /// Possible errors when prompting. #[derive(Debug)] pub enum PromptError { Io(io::Erro...
/// Prompt the user for a file name. pub fn name_file(phrase: &str) -> Result<String, PromptError> { print!("Please specify the name of the file{}", phrase); io::stdout().flush().expect("Failed to flush to stdout!"); let mut input = String::new(); match io::stdin().read_line(&mut input) { Ok(_...
{ let mut name_input = name(minchars); while name_input.is_err() { println!("Please enter at least {} letters.", minchars); name_input = name(minchars); } name_input.unwrap() }
identifier_body
prompts.rs
/// Functionality for prompting the user to make a choice or type some text. use std::io::{self, Write}; use std::cmp; use std::num; use rand::{self, Rng}; use std::fmt; use std::error; use std::rc::Rc; use std::cell::RefCell; /// Possible errors when prompting. #[derive(Debug)] pub enum PromptError { Io(io::Erro...
(question: &str, aff: &[&str], neg: &[&str], maxprompts: i32) -> bool { let mut numprompts = 0; while numprompts < maxprompts { match bool_choose(question, aff, neg) { Ok(c) => return c, Err(PromptError::Io(e)) => println!("{}", e), Err(_) =...
bool_choose_or_rand
identifier_name
http_cache.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/. */ use hyper::header::{Expires, HttpDate}; use hyper::method::Method; use hyper::status::StatusCode; use msg::conste...
}) }
assert!(refreshed_response.is_some()); match body { ResponseBody::Receiving(_) => assert!(done_chan.is_some()), ResponseBody::Empty | ResponseBody::Done(_) => assert!(done_chan.is_none()) }
random_line_split
http_cache.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/. */ use hyper::header::{Expires, HttpDate}; use hyper::method::Method; use hyper::status::StatusCode; use msg::conste...
cache.store(&request, &response); // Second, mutate the response into a 304 response, and refresh the stored one. response.status = Some(StatusCode::NotModified); let mut done_chan = Some(channel()); let refreshed_response = cache.refresh(&request, response, &mut done_chan); ...
{ let response_bodies = vec![ResponseBody::Receiving(vec![]), ResponseBody::Empty, ResponseBody::Done(vec![])]; let url = ServoUrl::parse("https://servo.org").unwrap(); let request = Request::from_init(RequestInit { url: url.clone(), ...
identifier_body
http_cache.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/. */ use hyper::header::{Expires, HttpDate}; use hyper::method::Method; use hyper::status::StatusCode; use msg::conste...
() { let response_bodies = vec![ResponseBody::Receiving(vec![]), ResponseBody::Empty, ResponseBody::Done(vec![])]; let url = ServoUrl::parse("https://servo.org").unwrap(); let request = Request::from_init(RequestInit { url: url.clone(), ...
test_refreshing_resource_sets_done_chan_the_appropriate_value
identifier_name
sliding_windows.rs
use std::cell::{Cell, UnsafeCell}; use std::fmt; use std::marker::PhantomData; #[cfg(nightly)] use std::iterator::FusedIterator; /// This holds the backing allocation for the `Window` of an `Adaptor`. /// /// See [sliding_windows](index.html) for more information. pub struct Storage<T> { window_size: usize, //...
debug_assert!(data.len() == self.window_size); // the storage is full, overwrite the last element let new_offset; if window_offset >= (self.window_size - 1) { new_offset = 0; } else { new_offset = window_offset + 1; } data[window_offset...
{ data.push(elt); return data.len() == self.window_size; }
conditional_block
sliding_windows.rs
use std::cell::{Cell, UnsafeCell}; use std::fmt; use std::marker::PhantomData; #[cfg(nightly)] use std::iterator::FusedIterator; /// This holds the backing allocation for the `Window` of an `Adaptor`. /// /// See [sliding_windows](index.html) for more information. pub struct Storage<T> { window_size: usize, //...
<'a, T: 'a> { data: *mut T, data_len: usize, current_index: usize, // number of next() calls made which returned Some(_) iteration_num: usize, _p: PhantomData<&'a T>, } impl<'a, T> Iterator for WindowIterMut<'a, T> { type Item = &'a mut T; fn next(&mut self) -> Option<Self::Item> { ...
WindowIterMut
identifier_name
sliding_windows.rs
use std::cell::{Cell, UnsafeCell}; use std::fmt; use std::marker::PhantomData; #[cfg(nightly)] use std::iterator::FusedIterator; /// This holds the backing allocation for the `Window` of an `Adaptor`. /// /// See [sliding_windows](index.html) for more information. pub struct Storage<T> { window_size: usize, //...
impl<'a, T> fmt::Debug for Window<'a, T> where T: fmt::Debug { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Window")?; return f.debug_list().entries(self.into_iter()).finish(); } } impl<'a, T> Drop for Window<'a, T> { fn drop(&mut self) { // set flag to indic...
iteration_num: 0, _p: PhantomData } } }
random_line_split
io.rs
//! This module defines IO functions. use core::fmt; use core::fmt::Write; /// The number of the print char syscall. const PRINT_CHAR_SYSCALL: u64 = 0; /// A dummy struct to implement fmt::Write on. struct StdOut; impl fmt::Write for StdOut { fn write_str(&mut self, s: &str) -> fmt::Result { for charact...
(character: char) { unsafe { syscall!(PRINT_CHAR_SYSCALL, character as u64); } }
print_char
identifier_name
io.rs
//! This module defines IO functions. use core::fmt; use core::fmt::Write; /// The number of the print char syscall. const PRINT_CHAR_SYSCALL: u64 = 0; /// A dummy struct to implement fmt::Write on. struct StdOut;
impl fmt::Write for StdOut { fn write_str(&mut self, s: &str) -> fmt::Result { for character in s.chars() { print_char(character); } Ok(()) } } /// Prints a line to the standard output. #[macro_export] macro_rules! println { ($fmt:expr) => (print!(concat!($fmt, "\n"))); ...
random_line_split
io.rs
//! This module defines IO functions. use core::fmt; use core::fmt::Write; /// The number of the print char syscall. const PRINT_CHAR_SYSCALL: u64 = 0; /// A dummy struct to implement fmt::Write on. struct StdOut; impl fmt::Write for StdOut { fn write_str(&mut self, s: &str) -> fmt::Result { for charact...
/// Prints a character to the screen. fn print_char(character: char) { unsafe { syscall!(PRINT_CHAR_SYSCALL, character as u64); } }
{ StdOut.write_fmt(args).unwrap(); }
identifier_body
mod.rs
//- // Copyright (c) 2016, 2017, Jason Lingle // // This file is part of Ensync. // // Ensync 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 la...
pub mod tree_walk;
random_line_split
error.rs
// Copyright 2021 lowRISC contributors. // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
{ } /// The length of a `bad checksum` message on the wire, in bytes. pub const BAD_CHECKSUM_LEN: usize = 0; impl Message<'_> for BadChecksum { const TYPE: ContentType = ContentType::BadChecksum; } impl<'a> FromWire<'a> for BadChecksum { fn from_wire<R: Read<'a>>(mut _r: R) -> Result<Self, FromWireError> { ...
BadChecksum
identifier_name
error.rs
// Copyright 2021 lowRISC contributors. // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
/// A message. /// /// A message is identified by a [`ContentType`]: /// /// This trait is not implemented by any of the message types /// /// [`ContentType`]: enum.ContentType.html pub trait Message<'req>: FromWire<'req> + ToWire { /// The unique [`ContentType`] for this `Message`. /// /// [`ContentType`]:...
random_line_split
from_bits.rs
use itertools::Itertools; use malachite_base::num::basic::traits::{NegativeOne, Zero}; use malachite_base::num::conversion::traits::ExactFrom; use malachite_base::num::logic::traits::BitAccess; use malachite_nz::integer::Integer; pub fn from_bits_asc_naive<I: Iterator<Item = bool>>(bits: I) -> Integer { let bits =...
}) { n.clear_bit(i); } } else { n = Integer::ZERO; for i in bits.iter().rev().enumerate().filter_map(|(i, &bit)| { if bit { Some(u64::exact_from(i)) } else { None } }) { n.set_bit(i); ...
None } else { Some(u64::exact_from(i)) }
random_line_split
from_bits.rs
use itertools::Itertools; use malachite_base::num::basic::traits::{NegativeOne, Zero}; use malachite_base::num::conversion::traits::ExactFrom; use malachite_base::num::logic::traits::BitAccess; use malachite_nz::integer::Integer; pub fn
<I: Iterator<Item = bool>>(bits: I) -> Integer { let bits = bits.collect_vec(); if bits.is_empty() { return Integer::ZERO; } let mut n; if *bits.last().unwrap() { n = Integer::NEGATIVE_ONE; for i in bits.iter() .enumerate() .filter_ma...
from_bits_asc_naive
identifier_name
from_bits.rs
use itertools::Itertools; use malachite_base::num::basic::traits::{NegativeOne, Zero}; use malachite_base::num::conversion::traits::ExactFrom; use malachite_base::num::logic::traits::BitAccess; use malachite_nz::integer::Integer; pub fn from_bits_asc_naive<I: Iterator<Item = bool>>(bits: I) -> Integer
.filter_map(|(i, &bit)| if bit { Some(u64::exact_from(i)) } else { None }) { n.set_bit(i); } }; n } pub fn from_bits_desc_naive<I: Iterator<Item = bool>>(bits: I) -> Integer { let bits = bits.collect_vec(); if bits.is_empty() { return Integer::ZERO; ...
{ let bits = bits.collect_vec(); if bits.is_empty() { return Integer::ZERO; } let mut n; if *bits.last().unwrap() { n = Integer::NEGATIVE_ONE; for i in bits.iter() .enumerate() .filter_map(|(i, &bit)| if bit { None } else { Some(u64...
identifier_body
from_bits.rs
use itertools::Itertools; use malachite_base::num::basic::traits::{NegativeOne, Zero}; use malachite_base::num::conversion::traits::ExactFrom; use malachite_base::num::logic::traits::BitAccess; use malachite_nz::integer::Integer; pub fn from_bits_asc_naive<I: Iterator<Item = bool>>(bits: I) -> Integer { let bits =...
else { n = Integer::ZERO; for i in bits.iter().rev().enumerate().filter_map(|(i, &bit)| { if bit { Some(u64::exact_from(i)) } else { None } }) { n.set_bit(i); } }; n }
{ n = Integer::NEGATIVE_ONE; for i in bits.iter().rev().enumerate().filter_map(|(i, &bit)| { if bit { None } else { Some(u64::exact_from(i)) } }) { n.clear_bit(i); } }
conditional_block
thin_vec.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 ...
<I: IntoIterator<Item = T>>(&mut self, iter: I) { match *self { ThinVec(Some(ref mut vec)) => vec.extend(iter), ThinVec(None) => *self = iter.into_iter().collect::<Vec<_>>().into(), } } }
extend
identifier_name
thin_vec.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 ...
} impl<T> Into<Vec<T>> for ThinVec<T> { fn into(self) -> Vec<T> { match self { ThinVec(None) => Vec::new(), ThinVec(Some(vec)) => *vec, } } } impl<T> ::std::ops::Deref for ThinVec<T> { type Target = [T]; fn deref(&self) -> &[T] { match *self { ...
{ if vec.is_empty() { ThinVec(None) } else { ThinVec(Some(Box::new(vec))) } }
identifier_body
thin_vec.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 ...
} } impl<T> Extend<T> for ThinVec<T> { fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) { match *self { ThinVec(Some(ref mut vec)) => vec.extend(iter), ThinVec(None) => *self = iter.into_iter().collect::<Vec<_>>().into(), } } }
fn deref(&self) -> &[T] { match *self { ThinVec(None) => &[], ThinVec(Some(ref vec)) => vec, }
random_line_split
set.rs
use super::{imp, Timestamp}; use std::fs::File; /// TODO: FIXME. pub trait SetTime { /// TODO: FIXME. fn set_creation(&mut self, time: Timestamp) -> Result<(), ()>; /// TODO: FIXME. fn set_last_access(&mut self, time: Timestamp) -> Result<(), ()>; /// TODO: FIXME. fn set_last_modification(&m...
}
{ imp::set_last_modification_time(self, time) }
identifier_body
set.rs
use std::fs::File; /// TODO: FIXME. pub trait SetTime { /// TODO: FIXME. fn set_creation(&mut self, time: Timestamp) -> Result<(), ()>; /// TODO: FIXME. fn set_last_access(&mut self, time: Timestamp) -> Result<(), ()>; /// TODO: FIXME. fn set_last_modification(&mut self, time: Timestamp) -> ...
use super::{imp, Timestamp};
random_line_split
set.rs
use super::{imp, Timestamp}; use std::fs::File; /// TODO: FIXME. pub trait SetTime { /// TODO: FIXME. fn set_creation(&mut self, time: Timestamp) -> Result<(), ()>; /// TODO: FIXME. fn set_last_access(&mut self, time: Timestamp) -> Result<(), ()>; /// TODO: FIXME. fn set_last_modification(&m...
(&mut self, time: Timestamp) -> Result<(), ()> { imp::set_last_access_time(self, time) } fn set_last_modification(&mut self, time: Timestamp) -> Result<(), ()> { imp::set_last_modification_time(self, time) } }
set_last_access
identifier_name
issue-3953.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 ...
(&self, other: &Lol) -> bool { **self == **other } } fn main() { if Lol(2) == Lol(4) { println!("2 == 4"); } else { println!("2!= 4"); } }
ne
identifier_name
issue-3953.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 ...
}
{ println!("2 != 4"); }
conditional_block
issue-3953.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 ...
println!("2 == 4"); } else { println!("2!= 4"); } }
fn main() { if Lol(2) == Lol(4) {
random_line_split
decoding.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 may...
<T: DataType>( bench: &mut Bencher, num_values: usize, batch_size: usize, buffer: ByteBufferPtr, mut decoder: Box<Decoder<T>>, ) { bench.bytes = buffer.len() as u64; bench.iter(|| { decoder .set_data(buffer.clone(), num_values) .expect("set_data() should be OK"); let mut values = vec![T:...
bench_decoding
identifier_name
decoding.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 may...
plain!(plain_i32_1k_32, 1024, 32, Int32Type, Type::INT32, gen_1000); plain!(plain_i32_1k_64, 1024, 64, Int32Type, Type::INT32, gen_1000); plain!( plain_i32_1k_128, 1024, 128, Int32Type, Type::INT32, gen_1000 ); plain!(plain_i32_1m_32, 1024, 32, Int32Type, Type::INT32, gen_1000); plain!(plain_i32_1m_64, 10...
{ bench.bytes = buffer.len() as u64; bench.iter(|| { decoder .set_data(buffer.clone(), num_values) .expect("set_data() should be OK"); let mut values = vec![T::T::default(); batch_size]; loop { if decoder.get(&mut values[..]).expect("get() should be OK") < batch_size { break; ...
identifier_body
decoding.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 may...
} }) } plain!(plain_i32_1k_32, 1024, 32, Int32Type, Type::INT32, gen_1000); plain!(plain_i32_1k_64, 1024, 64, Int32Type, Type::INT32, gen_1000); plain!( plain_i32_1k_128, 1024, 128, Int32Type, Type::INT32, gen_1000 ); plain!(plain_i32_1m_32, 1024, 32, Int32Type, Type::INT32, gen_1000); plain!(plain_...
{ break; }
conditional_block
decoding.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 may...
($fname:ident, $num_values:expr, $batch_size:expr, $ty:ident, $pty:expr, $gen_data_fn:expr) => { #[bench] fn $fname(bench: &mut Bencher) { let mem_tracker = Rc::new(MemTracker::new()); let mut encoder = PlainEncoder::<$ty>::new(Rc::new(col_desc(0, $pty)), mem_tracker, vec![]); le...
}; macro_rules! plain {
random_line_split
cell.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} }
let _ = _b; let _b = x.borrow_mut();
random_line_split
cell.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
#[test] fn no_mut_then_imm_borrow() { let x = RefCell::new(0); let _b1 = x.borrow_mut(); assert!(x.try_borrow().is_none()); } #[test] fn no_imm_then_borrow_mut() { let x = RefCell::new(0); let _b1 = x.borrow(); assert!(x.try_borrow_mut().is_none());...
{ let x = RefCell::new(0); let _b1 = x.borrow(); x.borrow(); }
identifier_body
cell.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { let x = RefCell::new(0); { let _b1 = x.borrow(); } x.borrow_mut(); } #[test] fn mut_release_borrow_mut() { let x = RefCell::new(0); { let _b1 = x.borrow_mut(); } x.borrow(); } #[test] fn double_borrow_...
imm_release_borrow_mut
identifier_name
svggraphicselement.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 crate::dom::bindings::inheritance::Castable; use crate::dom::document::Document; use crate::dom::svgelement::S...
}
{ Some(self.upcast::<SVGElement>() as &dyn VirtualMethods) }
identifier_body
svggraphicselement.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 crate::dom::bindings::inheritance::Castable; use crate::dom::document::Document; use crate::dom::svgelement::S...
impl VirtualMethods for SVGGraphicsElement { fn super_type(&self) -> Option<&dyn VirtualMethods> { Some(self.upcast::<SVGElement>() as &dyn VirtualMethods) } }
} } }
random_line_split
svggraphicselement.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 crate::dom::bindings::inheritance::Castable; use crate::dom::document::Document; use crate::dom::svgelement::S...
(&self) -> Option<&dyn VirtualMethods> { Some(self.upcast::<SVGElement>() as &dyn VirtualMethods) } }
super_type
identifier_name
mod.rs
// Copyright 2014 The rust-pcre authors. // // 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 ac...
(code: *const pcre, extra: *const ::PcreExtra, what: fullinfo_field, where_: *mut c_void) { assert!(!code.is_null()); let rc = native::pcre_fullinfo(code, extra, what, where_); if rc < 0 && rc!= PCRE_ERROR_NULL { panic!("pcre_fullinfo"); } } pub unsafe fn pcre_refcou...
pcre_fullinfo
identifier_name
mod.rs
// Copyright 2014 The rust-pcre authors. // // 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 ac...
pub unsafe fn pcre_study(code: *const ::detail::pcre, options: &EnumSet<::StudyOption>) -> *mut ::PcreExtra { assert!(!code.is_null()); let converted_options = options.iter().fold(0, |converted_options, option| { converted_options | (option as study_options) }); let mu...
{ assert!(!code.is_null()); let curr_refcount = native::pcre_refcount(code, 0); if curr_refcount + adjust < 0 { panic!("refcount underflow"); } else if curr_refcount + adjust > 65535 { panic!("refcount overflow"); } native::pcre_refcount(code, adjust) }
identifier_body
mod.rs
// Copyright 2014 The rust-pcre authors. // // 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 ac...
pub unsafe fn pcre_refcount(code: *mut ::detail::pcre, adjust: c_int) -> c_int { assert!(!code.is_null()); let curr_refcount = native::pcre_refcount(code, 0); if curr_refcount + adjust < 0 { panic!("refcount underflow"); } else if curr_refcount + adjust > 65535 { panic!("refcount overflo...
random_line_split