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
solver060.rs
// COPYRIGHT (C) 2017 barreiro. All Rights Reserved. // Rust solvers for Project Euler problems use std::collections::HashMap; use euler::algorithm::long::{concatenation, pow_10, square}; use euler::algorithm::prime::{generator_wheel, miller_rabin, prime_sieve}; use euler::Solver; // The primes 3, 7, 109, and 673, a...
(&self) -> isize { let (mut set, primes) = (vec![], generator_wheel().take_while(|&p| p < pow_10(self.n - 1)).collect::<Vec<_>>()); add_prime_to_set(&mut set, self.n as _, &primes, &mut HashMap::new()); set.iter().sum() } } fn add_prime_to_set<'a>(set: &mut Vec<isize>, size: usize, primes: ...
solve
identifier_name
solver060.rs
// COPYRIGHT (C) 2017 barreiro. All Rights Reserved. // Rust solvers for Project Euler problems use std::collections::HashMap; use euler::algorithm::long::{concatenation, pow_10, square}; use euler::algorithm::prime::{generator_wheel, miller_rabin, prime_sieve}; use euler::Solver; // The primes 3, 7, 109, and 673, a...
// Closure that takes an element of the set and does the intersection with the concatenations of other elements. // The outcome is the primes that form concatenations with all elements of the set. From there, try to increase the size of the set by recursion. let candidates = |p| cache.get(p).unwrap().iter()...
// Memoization of the prime concatenations for a 25% speedup, despite increasing code complexity significantly set.last().iter().for_each(|&&p| { cache.entry(p).or_insert_with(|| concatenation_list(p)); });
random_line_split
solver060.rs
// COPYRIGHT (C) 2017 barreiro. All Rights Reserved. // Rust solvers for Project Euler problems use std::collections::HashMap; use euler::algorithm::long::{concatenation, pow_10, square}; use euler::algorithm::prime::{generator_wheel, miller_rabin, prime_sieve}; use euler::Solver; // The primes 3, 7, 109, and 673, a...
}) }
{ set.pop(); false }
conditional_block
extractor.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 message::Message; use error::{Error, Result}; use common::{find_string, escape_string}; use std::collections::H...
() -> Extractor { Extractor { messages: HashMap::new(), orig_strings: HashMap::new(), } } /// Returns a hashmap mapping the original strings (as used by `lformat!`) /// to escaped strings. Only contains strings that are different and /// must thus be handled. ...
new
identifier_name
extractor.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 message::Message; use error::{Error, Result}; use common::{find_string, escape_string}; use std::collections::H...
if self.messages.contains_key(msg.as_str()) { self.messages.get_mut(&msg).unwrap().add_source(filename.as_str(), line); } else { let mut message = Message::new(msg.as_str()); message.add_source(filename.as_str(), line); ...
{ self.orig_strings.insert(orig_msg, msg.clone()); }
conditional_block
extractor.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 message::Message; use error::{Error, Result}; use common::{find_string, escape_string}; use std::collections::H...
if self.messages.contains_key(msg.as_str()) { self.messages.get_mut(&msg).unwrap().add_source(filename.as_str(), line); } else { let mut message = Message::new(msg.as_str()); message.add_source(filename.as_str(), line); ...
random_line_split
vulkano_gralloc.rs
// Copyright 2021 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //! vulkano_gralloc: Implements swapchain allocation and memory mapping //! using Vulkano. //! //! External code found at https://github.com/vulkano-rs...
}; use vulkano::instance::{Instance, InstanceCreationError, InstanceExtensions, Version}; use vulkano::memory::{ DedicatedAlloc, DeviceMemoryAllocError, DeviceMemoryBuilder, DeviceMemoryMapping, ExternalMemoryHandleType, MemoryRequirements, }; use vulkano::memory::pool::AllocFromRequirementsFilter; use vulka...
use vulkano::device::{Device, DeviceCreationError, DeviceExtensions}; use vulkano::image::{ sys, ImageCreateFlags, ImageCreationError, ImageDimensions, ImageUsage, SampleCount,
random_line_split
vulkano_gralloc.rs
// Copyright 2021 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //! vulkano_gralloc: Implements swapchain allocation and memory mapping //! using Vulkano. //! //! External code found at https://github.com/vulkano-rs...
fn get_image_memory_requirements( &mut self, info: ImageAllocationInfo, ) -> RutabagaResult<ImageMemoryRequirements> { let mut reqs: ImageMemoryRequirements = Default::default(); let (unsafe_image, memory_requirements) = unsafe { self.create_image(info)? }; let device...
{ for device in self.devices.values() { if !device.enabled_extensions().ext_external_memory_dma_buf { return false; } } true }
identifier_body
vulkano_gralloc.rs
// Copyright 2021 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //! vulkano_gralloc: Implements swapchain allocation and memory mapping //! using Vulkano. //! //! External code found at https://github.com/vulkano-rs...
(&self) -> bool { for device in self.devices.values() { if!device.enabled_extensions().ext_external_memory_dma_buf { return false; } } true } fn get_image_memory_requirements( &mut self, info: ImageAllocationInfo, ) -> Rutabag...
supports_dmabuf
identifier_name
opts.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/. */ //! Configuration options for a single run of the servo application. Created //! from command line arguments. use...
use extra::getopts; let args = args.tail(); let opts = ~[ getopts::optflag("c"), // CPU rendering getopts::optopt("o"), // output file getopts::optopt("r"), // rendering backend getopts::optopt("s"), // size of tiles getopts::optopt("t"), ...
random_line_split
opts.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/. */ //! Configuration options for a single run of the servo application. Created //! from command line arguments. use...
(args: &[~str]) -> Opts { use extra::getopts; let args = args.tail(); let opts = ~[ getopts::optflag("c"), // CPU rendering getopts::optopt("o"), // output file getopts::optopt("r"), // rendering backend getopts::optopt("s"), // size of tiles ...
from_cmdline_args
identifier_name
opts.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/. */ //! Configuration options for a single run of the servo application. Created //! from command line arguments. use...
} None => SkiaBackend }; let tile_size: uint = match opt_match.opt_str("s") { Some(tile_size_str) => FromStr::from_str(tile_size_str).unwrap(), None => 512, }; let n_render_threads: uint = match opt_match.opt_str("t") { Some(n_render_threads_str) => FromStr::fr...
{ fail!(~"unknown backend type") }
conditional_block
opts.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/. */ //! Configuration options for a single run of the servo application. Created //! from command line arguments. use...
let urls = if opt_match.free.is_empty() { fail!(~"servo asks that you provide 1 or more URLs") } else { opt_match.free.clone() }; let render_backend = match opt_match.opt_str("r") { Some(backend_str) => { if backend_str == ~"direct2d" { Direct2DBacken...
{ use extra::getopts; let args = args.tail(); let opts = ~[ getopts::optflag("c"), // CPU rendering getopts::optopt("o"), // output file getopts::optopt("r"), // rendering backend getopts::optopt("s"), // size of tiles getopts::optopt("t"), ...
identifier_body
partial_ord.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(cx: &mut ExtCtxt, span: Span, op: OrderingOp, self_arg_tags: &[ast::Ident]) -> P<ast::Expr> { let lft = cx.expr_ident(span, self_arg_tags[0]); let rgt = cx.expr_addr_of(span, cx.expr_ident(span, self_arg_tags[1])); ...
some_ordering_collapsed
identifier_name
partial_ord.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let ordering_ty = Literal(path_std!(cx, core::cmp::Ordering)); let ret_ty = Literal(Path::new_(pathvec_std!(cx, core::option::Option), None, vec![Box::new(ordering_ty)], true)); let inline = cx.meta_...
{ macro_rules! md { ($name:expr, $op:expr, $equal:expr) => { { let inline = cx.meta_word(span, InternedString::new("inline")); let attrs = vec!(cx.attribute(span, inline)); MethodDef { name: $name, generics: LifetimeBounds::empty(), ...
identifier_body
partial_ord.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
FIXME #6449: These `if`s could/should be `match`es. */ cs_fold( // foldr nests the if-elses correctly, leaving the first field // as the outermost one, and the last as the innermost. false, |cx, span, old, self_f, other_fs| { // let __test = new; // if...
} } else { __test }
random_line_split
fold.rs
use std::mem; use {Task, Future, Poll, IntoFuture}; use stream::Stream; /// A future used to collect all the results of a stream into one generic type. /// /// This future is returned by the `Stream::fold` method. pub struct
<S, F, Fut, T> where Fut: IntoFuture { stream: S, f: F, state: State<T, Fut::Future>, } enum State<T, Fut> { /// Placeholder state when doing work Empty, /// Ready to process the next stream item; current accumulator is the `T` Ready(T), /// Working on a future the process the previou...
Fold
identifier_name
fold.rs
use std::mem; use {Task, Future, Poll, IntoFuture}; use stream::Stream; /// A future used to collect all the results of a stream into one generic type. /// /// This future is returned by the `Stream::fold` method. pub struct Fold<S, F, Fut, T> where Fut: IntoFuture { stream: S, f: F, state: State<T, Fut::...
T: Send +'static { type Item = T; type Error = S::Error; fn poll(&mut self, task: &mut Task) -> Poll<T, S::Error> { loop { match mem::replace(&mut self.state, State::Empty) { State::Empty => panic!("cannot poll Fold twice"), State::Ready(state) ...
Fut::Error: Into<S::Error>,
random_line_split
extern-pass-TwoU32s.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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Test a foreig...
random_line_split
extern-pass-TwoU32s.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 ...
() { unsafe { let x = TwoU32s {one: 22, two: 23}; let y = rust_dbg_extern_identity_TwoU32s(x); assert_eq!(x, y); } }
main
identifier_name
test_sockopt.rs
use rand::{thread_rng, Rng}; use nix::sys::socket::{socket, sockopt, getsockopt, setsockopt, AddressFamily, SockType, SockFlag, SockProtocol}; #[cfg(any(target_os = "android", target_os = "linux"))] use crate::*; // NB: FreeBSD supports LOCAL_PEERCRED for SOCK_SEQPACKET, but OSX does not. #[cfg(any( target_os ...
#[test] fn test_so_tcp_keepalive() { let fd = socket(AddressFamily::Inet, SockType::Stream, SockFlag::empty(), SockProtocol::Tcp).unwrap(); setsockopt(fd, sockopt::KeepAlive, &true).unwrap(); assert!(getsockopt(fd, sockopt::KeepAlive).unwrap()); #[cfg(any(target_os = "android", target_o...
{ skip_if_not_root!("test_bindtodevice"); let fd = socket(AddressFamily::Inet, SockType::Stream, SockFlag::empty(), None).unwrap(); let val = getsockopt(fd, sockopt::BindToDevice).unwrap(); setsockopt(fd, sockopt::BindToDevice, &val).unwrap(); assert_eq!( getsockopt(fd, sockopt::BindToDev...
identifier_body
test_sockopt.rs
use rand::{thread_rng, Rng}; use nix::sys::socket::{socket, sockopt, getsockopt, setsockopt, AddressFamily, SockType, SockFlag, SockProtocol}; #[cfg(any(target_os = "android", target_os = "linux"))] use crate::*; // NB: FreeBSD supports LOCAL_PEERCRED for SOCK_SEQPACKET, but OSX does not. #[cfg(any( target_os ...
} } #[test] #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))] fn test_ttl_opts() { let fd4 = socket(AddressFamily::Inet, SockType::Datagram, SockFlag::empty(), None).unwrap(); setsockopt(fd4, sockopt::Ipv4Ttl, &1) .expect("setting ipv4ttl on an inet socket should succeed...
let x = getsockopt(fd, sockopt::TcpKeepInterval).unwrap(); setsockopt(fd, sockopt::TcpKeepInterval, &(x + 1)).unwrap(); assert_eq!(getsockopt(fd, sockopt::TcpKeepInterval).unwrap(), x + 1);
random_line_split
test_sockopt.rs
use rand::{thread_rng, Rng}; use nix::sys::socket::{socket, sockopt, getsockopt, setsockopt, AddressFamily, SockType, SockFlag, SockProtocol}; #[cfg(any(target_os = "android", target_os = "linux"))] use crate::*; // NB: FreeBSD supports LOCAL_PEERCRED for SOCK_SEQPACKET, but OSX does not. #[cfg(any( target_os ...
() { use nix::{ unistd::{Gid, Uid}, sys::socket::socketpair }; let (fd1, _fd2) = socketpair(AddressFamily::Unix, SockType::Stream, None, SockFlag::empty()).unwrap(); let xucred = getsockopt(fd1, sockopt::LocalPeerCred).unwrap(); assert_eq!(xucred.vers...
test_local_peercred_stream
identifier_name
gui.rs
use edit::Editor; use std::fmt::Write; use gtk::{self, Widget, Window, Frame, EventBox, DrawingArea, WindowPosition}; use gtk::signal::Inhibit; use gtk::traits::*; use gdk::EventType; use cairo::{Context, Antialias}; use cairo::enums::{FontSlant, FontWeight}; pub struct Gui { #[allow(dead_code)] win: &'static mut ...
c.fill(); } c.translate(-undo_x, SCALE + 10.0); } } }
let trans_x = SCALE * 8.0; undo_x += trans_x; c.translate(trans_x, 0.0); c.text_path(&s);
random_line_split
gui.rs
use edit::Editor; use std::fmt::Write; use gtk::{self, Widget, Window, Frame, EventBox, DrawingArea, WindowPosition}; use gtk::signal::Inhibit; use gtk::traits::*; use gdk::EventType; use cairo::{Context, Antialias}; use cairo::enums::{FontSlant, FontWeight}; pub struct Gui { #[allow(dead_code)] win: &'static mut...
(&self) { self.win.queue_draw(); } pub fn render(&self, w: Widget, c: Context) { let (_alloc_w, _alloc_h) = (w.get_allocated_width(), w.get_allocated_height()); const FONT_SIZE: f64 = 17.0; const SCALE: f64 = FONT_SIZE * 1.0; // 1.0 for Helvetica, c.select_font_face("Times New Roman", FontSlant::Norma...
dirty
identifier_name
gui.rs
use edit::Editor; use std::fmt::Write; use gtk::{self, Widget, Window, Frame, EventBox, DrawingArea, WindowPosition}; use gtk::signal::Inhibit; use gtk::traits::*; use gdk::EventType; use cairo::{Context, Antialias}; use cairo::enums::{FontSlant, FontWeight}; pub struct Gui { #[allow(dead_code)] win: &'static mut...
} s.push('}'); let trans_x = SCALE * 8.0; undo_x += trans_x; c.translate(trans_x, 0.0); c.text_path(&s); c.fill(); } c.translate(-undo_x, SCALE + 10.0); } } }
{ s.push(','); s.push(' '); }
conditional_block
main.rs
extern crate structopt; #[macro_use] extern crate structopt_derive; use structopt::StructOpt; use std::collections::BTreeSet; use std::fs::File; use std::io::Read; use std::path::PathBuf; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] struct Component { input: usize, output: usize, } imp...
(start: usize, components: &BTreeSet<Component>) -> usize { components .iter() .filter_map(|component| { if component.input == start { let mut new_set = components.clone(); new_set.remove(component); Some( max_strength(com...
max_strength
identifier_name
main.rs
extern crate structopt; #[macro_use] extern crate structopt_derive; use structopt::StructOpt; use std::collections::BTreeSet; use std::fs::File; use std::io::Read; use std::path::PathBuf; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] struct Component { input: usize, output: usize, } imp...
else { vec![] } }) .collect() } fn part2(components: &BTreeSet<Component>) -> usize { possibilities(0, components) .into_iter() .max_by(|a, b| { a.len() .cmp(&b.len()) .then_with(|| strength(a.clone()).cmp(&strength...
{ let mut new_set = components.clone(); new_set.remove(component); let mut ps = possibilities(component.input, &new_set); for mut p in &mut ps { p.push(component.flip()); } ps.push(vec![*component]); ...
conditional_block
main.rs
extern crate structopt; #[macro_use] extern crate structopt_derive; use structopt::StructOpt; use std::collections::BTreeSet; use std::fs::File; use std::io::Read; use std::path::PathBuf; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] struct Component { input: usize, output: usize, } imp...
fn possibilities( start: usize, components: &BTreeSet<Component>, ) -> Vec<Vec<Component>> { components .iter() .flat_map(|component| { if component.input == start { let mut new_set = components.clone(); new_set.remove(component); l...
{ max_strength(0, components) }
identifier_body
main.rs
extern crate structopt; #[macro_use] extern crate structopt_derive; use structopt::StructOpt; use std::collections::BTreeSet; use std::fs::File; use std::io::Read; use std::path::PathBuf; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] struct Component { input: usize, output: usize, } imp...
fn max_strength(start: usize, components: &BTreeSet<Component>) -> usize { components .iter() .filter_map(|component| { if component.input == start { let mut new_set = components.clone(); new_set.remove(component); Some( ...
iter.into_iter().map(|c| c.input + c.output).sum() }
random_line_split
build.rs
// Copyright 2015 Brendan Zabarauskas and the gl-rs developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required b...
() { let dest = env::var("OUT_DIR").unwrap(); let mut file = File::create(&Path::new(&dest).join("test_symbols.rs")).unwrap(); Registry::new(Api::Gl, (4, 5), Profile::Core, Fallbacks::All, ["GL_ARB_debug_output"]) .write_bindings(GlobalGenerator, &mut file) .unwrap(); }
main
identifier_name
build.rs
// Copyright 2015 Brendan Zabarauskas and the gl-rs developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 //
// distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. extern crate gl_generator; use gl_generator::*; use std::env; use st...
// Unless required by applicable law or agreed to in writing, software
random_line_split
build.rs
// Copyright 2015 Brendan Zabarauskas and the gl-rs developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required b...
{ let dest = env::var("OUT_DIR").unwrap(); let mut file = File::create(&Path::new(&dest).join("test_symbols.rs")).unwrap(); Registry::new(Api::Gl, (4, 5), Profile::Core, Fallbacks::All, ["GL_ARB_debug_output"]) .write_bindings(GlobalGenerator, &mut file) .unwrap(); }
identifier_body
ioapic.rs
/* SPDX-License-Identifier: GPL-2.0-only */ // to do: add a channel such that a local apic can send messages to io apic. use crate::err::Error; use crate::hv::interrupt_vcpu; use crate::{GuestThread, VCPU}; use crossbeam_channel::{Receiver, Sender}; #[allow(unused_imports)] use log::*; use std::sync::{Arc, Mutex, RwL...
let ioapic = ioapic.read().unwrap(); let vcpu_ids = vcpu_ids.read().unwrap(); let entry = ioapic.value[2 * irq as usize] as u64 | ((ioapic.value[2 * irq as usize + 1] as u64) << 32); let vector = (entry & 0xff) as u8; let dest = entry >> 56; ...
ioapic: Arc<RwLock<IoApic>>, vcpu_ids: Arc<RwLock<Vec<u32>>>, // the actual Hypervisor vcpu id of each guest thread ) { for irq in irq_receiver.iter() {
random_line_split
ioapic.rs
/* SPDX-License-Identifier: GPL-2.0-only */ // to do: add a channel such that a local apic can send messages to io apic. use crate::err::Error; use crate::hv::interrupt_vcpu; use crate::{GuestThread, VCPU}; use crossbeam_channel::{Receiver, Sender}; #[allow(unused_imports)] use log::*; use std::sync::{Arc, Mutex, RwL...
} pub fn ioapic_access( _vcpu: &VCPU, gth: &mut GuestThread, gpa: usize, reg_val: &mut u64, _size: u8, store: bool, ) -> Result<(), Error> { let offset = gpa & 0xfffff; if offset!= 0 && offset!= 0x10 { error!( "Bad register offset: {:x} and has to be 0x0 or 0x10", ...
{ if offset == 0 { self.reg } else { match self.reg { 0 => self.id, 1 => (IOAPIC_NUM_PINS << 16) | IOAPIC_VERSION, // 0x170011, 2 => self.arbid, 0x10..=IOAPIC_REG_MAX => self.value[self.reg as usize - 0x10], ...
identifier_body
ioapic.rs
/* SPDX-License-Identifier: GPL-2.0-only */ // to do: add a channel such that a local apic can send messages to io apic. use crate::err::Error; use crate::hv::interrupt_vcpu; use crate::{GuestThread, VCPU}; use crossbeam_channel::{Receiver, Sender}; #[allow(unused_imports)] use log::*; use std::sync::{Arc, Mutex, RwL...
(&self, offset: usize) -> u32 { if offset == 0 { self.reg } else { match self.reg { 0 => self.id, 1 => (IOAPIC_NUM_PINS << 16) | IOAPIC_VERSION, // 0x170011, 2 => self.arbid, 0x10..=IOAPIC_REG_MAX => self.value[self....
read
identifier_name
ioapic.rs
/* SPDX-License-Identifier: GPL-2.0-only */ // to do: add a channel such that a local apic can send messages to io apic. use crate::err::Error; use crate::hv::interrupt_vcpu; use crate::{GuestThread, VCPU}; use crossbeam_channel::{Receiver, Sender}; #[allow(unused_imports)] use log::*; use std::sync::{Arc, Mutex, RwL...
let ioapic = &gth.vm.ioapic; if store { ioapic.write().unwrap().write(offset, *reg_val as u32); } else { *reg_val = ioapic.read().unwrap().read(offset) as u64; } Ok(()) }
{ error!( "Bad register offset: {:x} and has to be 0x0 or 0x10", offset ); return Ok(()); }
conditional_block
meminfo.rs
extern crate linux_stats; use linux_stats::MemInfo; const MEMINFO_1: MemInfo = MemInfo { mem_total: 3521920, mem_free: 1878240, mem_available: 2275916, bufers: 35428, cached: 386132, swap_cached: 0, active: 134352, inactive: 266336, active_anon: 1094728, inactive_anon: 17664, ...
() { assert_eq!("".parse::<MemInfo>().unwrap(), Default::default()); } #[test] fn meminfo_1() { assert_eq!(MEMINFO_1_RAW.parse::<MemInfo>().unwrap(), MEMINFO_1); } #[test] fn meminfo_2() { assert_eq!(MEMINFO_2_RAW.parse::<MemInfo>().unwrap(), MEMINFO_2); }
meminfo_empty
identifier_name
meminfo.rs
extern crate linux_stats; use linux_stats::MemInfo; const MEMINFO_1: MemInfo = MemInfo { mem_total: 3521920, mem_free: 1878240, mem_available: 2275916, bufers: 35428, cached: 386132, swap_cached: 0, active: 134352, inactive: 266336, active_anon: 1094728, inactive_anon: 17664, ...
huge_pages_total: 0, huge_pages_free: 0, huge_pages_rsvd: 0, huge_pages_surp: 0, hugepagesize: 2048, direct_map_4k: 67520, direct_map_2m: 3602432, }; const MEMINFO_2: MemInfo = MemInfo { mem_total: 32828552, mem_free: 12195628, mem_available: 13725248, bufers: 185048, ca...
random_line_split
meminfo.rs
extern crate linux_stats; use linux_stats::MemInfo; const MEMINFO_1: MemInfo = MemInfo { mem_total: 3521920, mem_free: 1878240, mem_available: 2275916, bufers: 35428, cached: 386132, swap_cached: 0, active: 134352, inactive: 266336, active_anon: 1094728, inactive_anon: 17664, ...
#[test] fn meminfo_1() { assert_eq!(MEMINFO_1_RAW.parse::<MemInfo>().unwrap(), MEMINFO_1); } #[test] fn meminfo_2() { assert_eq!(MEMINFO_2_RAW.parse::<MemInfo>().unwrap(), MEMINFO_2); }
{ assert_eq!("".parse::<MemInfo>().unwrap(), Default::default()); }
identifier_body
harfbuzz.rs
codepoint: GlyphId, advance: Au, offset: Option<Point2D<Au>>, } impl ShapedGlyphData { pub fn
(buffer: *mut hb_buffer_t) -> ShapedGlyphData { unsafe { let mut glyph_count = 0; let glyph_infos = hb_buffer_get_glyph_infos(buffer, &mut glyph_count); assert!(!glyph_infos.is_null()); let mut pos_count = 0; let pos_infos = hb_buffer_get_glyph_positio...
new
identifier_name
harfbuzz.rs
y_offset = Au::from_f64_px(y_offset); let x_advance = Au::from_f64_px(x_advance); let y_advance = Au::from_f64_px(y_advance); let offset = if x_offset == Au(0) && y_offset == Au(0) && y_advance == Au(0) { None } else { // adjust the pen.....
Shaper::float_to_fixed(advance) } }
random_line_split
harfbuzz.rs
codepoint: GlyphId, advance: Au, offset: Option<Point2D<Au>>, } impl ShapedGlyphData { pub fn new(buffer: *mut hb_buffer_t) -> ShapedGlyphData { unsafe { let mut glyph_count = 0; let glyph_infos = hb_buffer_get_glyph_infos(buffer, &mut glyph_count); assert!(!gly...
i); } debug!("{} -> {}", i, loc); } debug!("text: {:?}", text); debug!("(char idx): char->(glyph index):"); for (i, ch) in text.char_indices() { debug!("{}: {:?} --> {}", i, ch, byte_to_glyph[i]); } let mut glyp...
{ let glyph_data = ShapedGlyphData::new(buffer); let glyph_count = glyph_data.len(); let byte_max = text.len(); debug!("Shaped text[byte count={}], got back {} glyph info records.", byte_max, glyph_count); // make map of what chars have glyphs ...
identifier_body
issue-60726.rs
use std::marker::PhantomData; pub struct True; pub struct False; pub trait InterfaceType{ type Send; }
pub struct DynTrait<I>{ _interface:PhantomData<fn()->I>, _unsync_unsend:PhantomData<::std::rc::Rc<()>>, } unsafe impl<I> Send for DynTrait<I> where I:InterfaceType<Send=True> {} // @has issue_60726/struct.IntoIter.html // @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h...
pub struct FooInterface<T>(PhantomData<fn()->T>); impl<T> InterfaceType for FooInterface<T> { type Send=False; }
random_line_split
issue-60726.rs
use std::marker::PhantomData; pub struct True; pub struct
; pub trait InterfaceType{ type Send; } pub struct FooInterface<T>(PhantomData<fn()->T>); impl<T> InterfaceType for FooInterface<T> { type Send=False; } pub struct DynTrait<I>{ _interface:PhantomData<fn()->I>, _unsync_unsend:PhantomData<::std::rc::Rc<()>>, } unsafe impl<I> Send for DynTrait<I> wh...
False
identifier_name
duplicate.rs
// Copyright 2014 Pierre Talbot (IRCAM) // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to...
} struct DuplicateItem<'a, Item> { cx: &'a ExtCtxt<'a>, items: HashMap<Ident, Item>, has_duplicate: bool, what_is_duplicated: String } impl<'a, Item> DuplicateItem<'a, Item> where Item: ItemIdent + ItemSpan { pub fn analyse<ItemIter>(cx: &'a ExtCtxt<'a>, iter: ItemIter, item_kind: String) -> Partial<H...
{ self.name.span.clone() }
identifier_body
duplicate.rs
// Copyright 2014 Pierre Talbot (IRCAM) // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to...
else { others.push(item); } } DuplicateItem::analyse(cx, functions.into_iter(), String::from("rust function")) .map(move |functions| { grammar.rust_functions = functions; grammar.rust_items = others; grammar }) } impl ItemIdent for rust::Item { fn ident(&self) -> Ident { ...
{ functions.push(item); }
conditional_block
duplicate.rs
// Copyright 2014 Pierre Talbot (IRCAM) // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to...
(&self) -> Ident { self.deref().ident() } } impl<InnerItem: ItemSpan> ItemSpan for rust::P<InnerItem> { fn span(&self) -> Span { self.deref().span() } } impl ItemIdent for Rule { fn ident(&self) -> Ident { self.name.node.clone() } } impl ItemSpan for Rule { fn span(&self) -> Span { self.n...
ident
identifier_name
duplicate.rs
// Copyright 2014 Pierre Talbot (IRCAM) // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to...
} fn duplicate_items(&self, pre: &Item, current: Item) { self.cx.span_err(current.span(), format!( "duplicate definition of {} `{}`", self.what_is_duplicated, current.ident()).as_str()); self.cx.span_note(pre.span(), format!( "previous definition of {} `{}` here", self.what_is_dupli...
} else { self.items.insert(ident, item); } } self
random_line_split
sudoku_solve.rs
// Part of Cosmos by OpenGenus const N: usize = 9; const UNASSIGNED: u8 = 0; type Board = [[u8; N]; N]; fn solve_sudoku(grid: &mut Board) -> bool { let row; let col; if let Some((r, c)) = find_unassigned_cells(&grid) { row = r; col = c; } else { // SOLVED return true; ...
fn print_grid(grid: &Board) { for row in grid.iter().take(N) { for col in 0..N { print!("{} ", row[col]); } println!(); } } #[test] fn test1() { let mut board = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, ...
{ for (row, _) in grid.iter().enumerate().take(N) { for col in 0..N { if grid[row][col] == UNASSIGNED { return Some((row, col)); } } } None }
identifier_body
sudoku_solve.rs
// Part of Cosmos by OpenGenus const N: usize = 9; const UNASSIGNED: u8 = 0; type Board = [[u8; N]; N]; fn solve_sudoku(grid: &mut Board) -> bool { let row; let col; if let Some((r, c)) = find_unassigned_cells(&grid) { row = r; col = c; } else { // SOLVED return true; ...
(grid: &Board) -> Option<(usize, usize)> { for (row, _) in grid.iter().enumerate().take(N) { for col in 0..N { if grid[row][col] == UNASSIGNED { return Some((row, col)); } } } None } fn print_grid(grid: &Board) { for row in grid.iter().take(N) { ...
find_unassigned_cells
identifier_name
sudoku_solve.rs
// Part of Cosmos by OpenGenus const N: usize = 9; const UNASSIGNED: u8 = 0; type Board = [[u8; N]; N]; fn solve_sudoku(grid: &mut Board) -> bool { let row; let col; if let Some((r, c)) = find_unassigned_cells(&grid) { row = r; col = c; } else { // SOLVED return true; ...
[4, 1, 6, 5, 3, 7, 2, 9, 8], [5, 7, 9, 1, 8, 2, 4, 6, 3], [3, 2, 8, 6, 9, 4, 7, 5, 1], [9, 4, 1, 8, 2, 5, 6, 3, 7], [7, 5, 2, 4, 6, 3, 8, 1, 9], [8, 6, 3, 7, 1, 9, 5, 4, 2], ]; assert_eq!(board, solved); }
random_line_split
sudoku_solve.rs
// Part of Cosmos by OpenGenus const N: usize = 9; const UNASSIGNED: u8 = 0; type Board = [[u8; N]; N]; fn solve_sudoku(grid: &mut Board) -> bool { let row; let col; if let Some((r, c)) = find_unassigned_cells(&grid) { row = r; col = c; } else
for num in 1..=9 { if is_safe(&grid, row, col, num) { grid[row][col] = num; if solve_sudoku(grid) { return true; } // Failed, try again grid[row][col] = UNASSIGNED; } } false } fn used_in_row(grid: &Board, row: u...
{ // SOLVED return true; }
conditional_block
basic.rs
// run-pass #![feature(trait_upcasting)] #![allow(incomplete_features)] trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { fn a(&self) -> i32 { 10 } fn z(&self) -> i32 { 11 } fn y(&self) -> i32 { 12 } } trait Bar: Foo {
fn b(&self) -> i32 { 20 } fn w(&self) -> i32 { 21 } } trait Baz: Bar { fn c(&self) -> i32 { 30 } } impl Foo for i32 { fn a(&self) -> i32 { 100 } } impl Bar for i32 { fn b(&self) -> i32 { 200 } } impl Baz for i32 { fn c(&self) -> i3...
random_line_split
basic.rs
// run-pass #![feature(trait_upcasting)] #![allow(incomplete_features)] trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { fn a(&self) -> i32 { 10 } fn z(&self) -> i32
fn y(&self) -> i32 { 12 } } trait Bar: Foo { fn b(&self) -> i32 { 20 } fn w(&self) -> i32 { 21 } } trait Baz: Bar { fn c(&self) -> i32 { 30 } } impl Foo for i32 { fn a(&self) -> i32 { 100 } } impl Bar for i32 { fn b(&self) -> i32...
{ 11 }
identifier_body
basic.rs
// run-pass #![feature(trait_upcasting)] #![allow(incomplete_features)] trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { fn a(&self) -> i32 { 10 } fn z(&self) -> i32 { 11 } fn y(&self) -> i32 { 12 } } trait Bar: Foo { fn b(&self) -> i32 { 20 ...
(&self) -> i32 { 100 } } impl Bar for i32 { fn b(&self) -> i32 { 200 } } impl Baz for i32 { fn c(&self) -> i32 { 300 } } fn main() { let baz: &dyn Baz = &1; let _: &dyn std::fmt::Debug = baz; assert_eq!(*baz, 1); assert_eq!(baz.a(), 100); assert_eq!(baz...
a
identifier_name
main.rs
extern crate paint; use paint::{ Layer, Canvas, Projection, Color, Size }; struct BigWhiteCircle; impl Layer for BigWhiteCircle { fn draw(&self, projection: Projection)->Color { use std::cmp:: { max, min }; let origin_x = std::u32::MAX / 2; let offset_x = max(projection.x, origin_x) - min(projection.x, origin_...
} struct TwoLayer<U: Layer, V: Layer> { a: U, b: V } impl<U: Layer, V: Layer> Layer for TwoLayer<U, V> { fn draw(&self, projection: Projection)->Color { projection.proxy_split(|p|self.a.draw(p), |p|self.b.draw(p)) } } fn main() { let args = std::os::args(); if args.len() == 2 { match std::path::Path::new_o...
{ let ball = Ball { origin: Position(3f32, 30f32, 3f32), radius: 3f32 }; let light = Light { origin: Position(0f32, 0f32, 0f32) }; let eye = Position(3f32, 0f32, 3f32); Scene { ball: ball, light: light, eye: eye } }
identifier_body
main.rs
extern crate paint; use paint::{ Layer, Canvas, Projection, Color, Size }; struct BigWhiteCircle; impl Layer for BigWhiteCircle { fn draw(&self, projection: Projection)->Color { use std::cmp:: { max, min }; let origin_x = std::u32::MAX / 2; let offset_x = max(projection.x, origin_x) - min(projection.x, origin_...
} fn main() { let args = std::os::args(); if args.len() == 2 { match std::path::Path::new_opt(&*args[1]) { Some(ref path) => { match std::io::fs::File::create(path) { Ok(ref mut file) => { let canvas = Canvas::new(Color::rgb(0, 200, 0), Size::new(260, 520)); let layer = TwoLayer { a: BigWhi...
}
random_line_split
main.rs
extern crate paint; use paint::{ Layer, Canvas, Projection, Color, Size }; struct BigWhiteCircle; impl Layer for BigWhiteCircle { fn draw(&self, projection: Projection)->Color { use std::cmp:: { max, min }; let origin_x = std::u32::MAX / 2; let offset_x = max(projection.x, origin_x) - min(projection.x, origin_...
, Err(x)=>println!(" {}", x) } }, None =>println!("failed to open path") } } else { println!("Usage: {} file_path \t write a ppm file", &*args[0]) } }
{ let canvas = Canvas::new(Color::rgb(0, 200, 0), Size::new(260, 520)); let layer = TwoLayer { a: BigWhiteCircle, b: BigWhiteCircle }; canvas.render(layer, file); }
conditional_block
main.rs
extern crate paint; use paint::{ Layer, Canvas, Projection, Color, Size }; struct BigWhiteCircle; impl Layer for BigWhiteCircle { fn draw(&self, projection: Projection)->Color { use std::cmp:: { max, min }; let origin_x = std::u32::MAX / 2; let offset_x = max(projection.x, origin_x) - min(projection.x, origin_...
()->Scene { let ball = Ball { origin: Position(3f32, 30f32, 3f32), radius: 3f32 }; let light = Light { origin: Position(0f32, 0f32, 0f32) }; let eye = Position(3f32, 0f32, 3f32); Scene { ball: ball, light: light, eye: eye } } } struct TwoLayer<U: Layer, V: Layer> { a: U, b: V } impl<U: Layer, V: Layer> Laye...
new
identifier_name
common.rs
use std::str::FromStr; use std::fmt::{Show, Formatter, Error}; use std::error; use simple::parse; #[deriving(Show)] pub struct AddrError { pub msg: String } impl error::Error for AddrError { fn
(&self) -> &str { self.msg.as_slice() } } #[deriving(PartialEq)] pub struct EmailAddress { pub local: String, pub domain: String, } impl EmailAddress { pub fn new(string: &str) -> EmailAddress { parse(string).unwrap() } } impl Show for EmailAddress { fn fmt(&self, f: &mut Form...
description
identifier_name
common.rs
use std::str::FromStr; use std::fmt::{Show, Formatter, Error}; use std::error; use simple::parse; #[deriving(Show)] pub struct AddrError { pub msg: String } impl error::Error for AddrError { fn description(&self) -> &str { self.msg.as_slice() } } #[deriving(PartialEq)] pub struct EmailAddress { ...
fn from_str(string: &str) -> Option<EmailAddress> { match parse(string) { Ok(s) => Some(s), Err(_) => None, } } }
random_line_split
common.rs
use std::str::FromStr; use std::fmt::{Show, Formatter, Error}; use std::error; use simple::parse; #[deriving(Show)] pub struct AddrError { pub msg: String } impl error::Error for AddrError { fn description(&self) -> &str { self.msg.as_slice() } } #[deriving(PartialEq)] pub struct EmailAddress { ...
} impl FromStr for EmailAddress { fn from_str(string: &str) -> Option<EmailAddress> { match parse(string) { Ok(s) => Some(s), Err(_) => None, } } }
{ write!(f, "{}@{}", self.local, self.domain) }
identifier_body
extents.rs
use std::convert::TryFrom; use std::io; use anyhow::ensure; use anyhow::Error; use positioned_io::ReadAt; use crate::assumption_failed; use crate::read_le16; use crate::read_le32; #[derive(Debug)] struct Extent { /// The docs call this 'block' (like everything else). I've invented a different name. part: u32...
assert_eq!(vec![40, 41, 42, 43, 80, 81, 82, 83, 84, 85, 86, 87], res); } #[test] fn zero_buf() { let mut buf = [7u8; 5]; assert_eq!(7, buf[0]); crate::extents::zero(&mut buf); for i in &buf { assert_eq!(0, *i); } } }
random_line_split
extents.rs
use std::convert::TryFrom; use std::io; use anyhow::ensure; use anyhow::Error; use positioned_io::ReadAt; use crate::assumption_failed; use crate::read_le16; use crate::read_le32; #[derive(Debug)] struct Extent { /// The docs call this 'block' (like everything else). I've invented a different name. part: u32...
FoundPart::Sparse(max) => { let max_bytes = u64::from(max) * block_size; let read = std::cmp::min(max_bytes, buf.len() as u64) as usize; let read = std::cmp::min(read as u64, self.len - self.pos) as usize; zero(&mut buf[0..read]); ...
{ let bytes_through_extent = (block_size * u64::from(wanted_block - extent.part)) + read_of_this_block; let remaining_bytes_in_extent = (u64::from(extent.len) * block_size) - bytes_through_extent; let to_read = std::cmp::min(remaini...
conditional_block
extents.rs
use std::convert::TryFrom; use std::io; use anyhow::ensure; use anyhow::Error; use positioned_io::ReadAt; use crate::assumption_failed; use crate::read_le16; use crate::read_le32; #[derive(Debug)] struct Extent { /// The docs call this 'block' (like everything else). I've invented a different name. part: u32...
(buf: &mut [u8]) { unsafe { std::ptr::write_bytes(buf.as_mut_ptr(), 0u8, buf.len()) } } #[cfg(test)] mod tests { use std::convert::TryFrom; use std::io::Read; use crate::extents::Extent; use crate::extents::TreeReader; #[test] fn simple_tree() { let data = (0..255u8).collect::<Vec...
zero
identifier_name
extents.rs
use std::convert::TryFrom; use std::io; use anyhow::ensure; use anyhow::Error; use positioned_io::ReadAt; use crate::assumption_failed; use crate::read_le16; use crate::read_le32; #[derive(Debug)] struct Extent { /// The docs call this 'block' (like everything else). I've invented a different name. part: u32...
self.pos += u64::try_from(read).expect("infallible u64 conversion"); Ok(read) } FoundPart::Sparse(max) => { let max_bytes = u64::from(max) * block_size; let read = std::cmp::min(max_bytes, buf.len() as u64) as usize; ...
{ if buf.is_empty() { return Ok(0); } let block_size = u64::from(self.block_size); let wanted_block = u32::try_from(self.pos / block_size).unwrap(); let read_of_this_block = self.pos % block_size; match find_part(wanted_block, &self.extents) { F...
identifier_body
error.rs
use postgres::error::Error as PostgresError; use std::error::Error as StdError; use std::fmt; use std::result::Result as StdResult; pub type Result<T> = StdResult<T, Error>; #[derive(Debug)] pub enum Error { Postgres(PostgresError), CategoryNameEmpty, CategoryNotFound, ColumnNotFound, FeedNameEmpt...
Error::CategoryNotFound => "Category not found", Error::ColumnNotFound => "Can't fetch a column", Error::FeedNameEmpty => "Feed name is empty", Error::FeedUrlEmpty => "Feed URL is empty", Error::FeedNotFound => "Feed not found", Error::TokenNotFoun...
match *self { Error::Postgres(ref err) => err.description(), Error::CategoryNameEmpty => "Category name is empty",
random_line_split
error.rs
use postgres::error::Error as PostgresError; use std::error::Error as StdError; use std::fmt; use std::result::Result as StdResult; pub type Result<T> = StdResult<T, Error>; #[derive(Debug)] pub enum Error { Postgres(PostgresError), CategoryNameEmpty, CategoryNotFound, ColumnNotFound, FeedNameEmpt...
fn cause(&self) -> Option<&StdError> { match *self { Error::Postgres(ref err) => Some(err), _ => None, } } } impl fmt::Display for Error { fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result { write!(out, "{}", self.description()) } }
{ match *self { Error::Postgres(ref err) => err.description(), Error::CategoryNameEmpty => "Category name is empty", Error::CategoryNotFound => "Category not found", Error::ColumnNotFound => "Can't fetch a column", Error::FeedNameEmpty => "Feed name is...
identifier_body
error.rs
use postgres::error::Error as PostgresError; use std::error::Error as StdError; use std::fmt; use std::result::Result as StdResult; pub type Result<T> = StdResult<T, Error>; #[derive(Debug)] pub enum Error { Postgres(PostgresError), CategoryNameEmpty, CategoryNotFound, ColumnNotFound, FeedNameEmpt...
(&self) -> Option<&StdError> { match *self { Error::Postgres(ref err) => Some(err), _ => None, } } } impl fmt::Display for Error { fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result { write!(out, "{}", self.description()) } }
cause
identifier_name
abi.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ // NB: This ordering MUST match the AbiDatas array below. // (This is ensured by the test indices_are_correct().) // Single platform ABIs come first (`for_arch()` relies on this) Cdecl, Stdcall, Fastcall, Aapcs, Win64, // Multiplatform ABIs second Rust, C, System, ...
Abi
identifier_name
abi.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
X86_64, Arm, Mips, Mipsel } impl Copy for Architecture {} pub struct AbiData { abi: Abi, // Name of this ABI as we like it called. name: &'static str, } impl Copy for AbiData {} pub enum AbiArchitecture { /// Not a real ABI (e.g., intrinsic) RustArch, /// An ABI that specifi...
random_line_split
abi.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} impl fmt::Show for Abi { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "\"{}\"", self.name()) } } impl fmt::Show for Os { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { OsLinux => "linux".fmt(f), OsWindows => "windows".fmt...
{ self.data().name }
identifier_body
send_serial.rs
use printspool_machine::components::ControllerConfig; use super::*; use crate::gcode_parser::parse_gcode; pub fn send_serial( effects: &mut Vec<Effect>, gcode_line: GCodeLine, context: &mut Context, is_polling: bool, ) { // Allow for a byte of spacing between receiving and sending over the serial ...
.map_err(|err| warn!("{}", err)); let ControllerConfig { long_running_code_timeout, fast_code_timeout, long_running_codes, blocking_codes, .. } = &context.controller.model; let mut duration = fast_code_timeout; let mut is_blocking = false; if let Ok(...
// eprintln!("TX: {:?}", gcode_line.gcode); context.push_gcode_tx(gcode_line.gcode.clone(), is_polling); let parser_result = parse_gcode(&gcode_line.gcode, context)
random_line_split
send_serial.rs
use printspool_machine::components::ControllerConfig; use super::*; use crate::gcode_parser::parse_gcode; pub fn send_serial( effects: &mut Vec<Effect>, gcode_line: GCodeLine, context: &mut Context, is_polling: bool, )
} = &context.controller.model; let mut duration = fast_code_timeout; let mut is_blocking = false; if let Ok(Some((mnemonic, major_number))) = parser_result { let gcode_macro = format!("{}{}", mnemonic, major_number); if long_running_codes.contains(&gcode_macro) { duration...
{ // Allow for a byte of spacing between receiving and sending over the serial port // The choice of 1 byte was arbitrary but sending without a spin lock seems to // loose GCodes. // let seconds_per_bit: u64 = (60 * 1000 * 1000 / context.baud_rate).into(); // spin_sleep::sleep(Duration::from_micros(...
identifier_body
send_serial.rs
use printspool_machine::components::ControllerConfig; use super::*; use crate::gcode_parser::parse_gcode; pub fn
( effects: &mut Vec<Effect>, gcode_line: GCodeLine, context: &mut Context, is_polling: bool, ) { // Allow for a byte of spacing between receiving and sending over the serial port // The choice of 1 byte was arbitrary but sending without a spin lock seems to // loose GCodes. // let second...
send_serial
identifier_name
send_serial.rs
use printspool_machine::components::ControllerConfig; use super::*; use crate::gcode_parser::parse_gcode; pub fn send_serial( effects: &mut Vec<Effect>, gcode_line: GCodeLine, context: &mut Context, is_polling: bool, ) { // Allow for a byte of spacing between receiving and sending over the serial ...
; effects.push(Effect::SendSerial(gcode_line)); if is_blocking { effects.push( Effect::CancelDelay { key: "tickle_delay".to_string() } ); } else { effects.push( Effect::Delay { key: "tickle_delay".to_string(), // TODO: configur...
{ let gcode_macro = format!("{}{}", mnemonic, major_number); if long_running_codes.contains(&gcode_macro) { duration = long_running_code_timeout } is_blocking = blocking_codes.contains(&gcode_macro) }
conditional_block
owned.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 ...
} /// Extension methods for an owning `Any+Send` trait object pub trait AnySendOwnExt { /// Returns the boxed value if it is of type `T`, or /// `Err(Self)` if it isn't. fn move_send<T:'static>(self) -> Result<Box<T>, Self>; } impl AnySendOwnExt for Box<Any+Send> { #[inline] fn move_send<T:'stati...
{ if self.is::<T>() { unsafe { // Get the raw representation of the trait object let to: TraitObject = *mem::transmute::<&Box<Any>, &TraitObject>(&self); // Prevent destructor on self being run intrinsics::forget(se...
identifier_body
owned.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 ...
} } impl fmt::Show for Box<Any> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("Box<Any>") } } #[cfg(test)] mod test { #[test] fn test_owned_clone() { let a = box 5i; let b: Box<int> = a.clone(); assert!(a == b); } #[test] fn any_move() ...
impl<T: fmt::Show> fmt::Show for Box<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f)
random_line_split
owned.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: &Box<T>) -> bool { *(*self) > *(*other) } } impl<T: Ord> Ord for Box<T> { #[inline] fn cmp(&self, other: &Box<T>) -> Ordering { (**self).cmp(*other) } } impl<T: Eq> Eq for Box<T> {} /// Extension methods for an owning `Any` trait object pub trait AnyOwnExt { /// Returns the boxed value if it...
gt
identifier_name
owned.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 ...
else { Err(self) } } } /// Extension methods for an owning `Any+Send` trait object pub trait AnySendOwnExt { /// Returns the boxed value if it is of type `T`, or /// `Err(Self)` if it isn't. fn move_send<T:'static>(self) -> Result<Box<T>, Self>; } impl AnySendOwnExt for Box<Any+Se...
{ unsafe { // Get the raw representation of the trait object let to: TraitObject = *mem::transmute::<&Box<Any>, &TraitObject>(&self); // Prevent destructor on self being run intrinsics::forget(self); // Ext...
conditional_block
main.rs
pub mod release; use std::env::args; use std::process::exit; use crate::release::*; use compat::getpid; use config::Config; use logger::{Level, Logger}; use networking::Server; fn main() { let mut config = Config::new(Logger::new(Level::Notice)); if let Some(f) = args().nth(1)
let (port, daemonize) = (config.port, config.daemonize); let mut server = Server::new(config); { let mut db = server.get_mut_db(); db.git_sha1 = GIT_SHA1; db.git_dirty = GIT_DIRTY; db.version = env!("CARGO_PKG_VERSION"); db.rustc_version = RUSTC_VERSION; } ...
{ if config.parsefile(f).is_err() { exit(1); } }
conditional_block
main.rs
pub mod release; use std::env::args; use std::process::exit; use crate::release::*; use compat::getpid; use config::Config; use logger::{Level, Logger}; use networking::Server; fn main()
println!("PID: {}", getpid()); } server.run(); }
{ let mut config = Config::new(Logger::new(Level::Notice)); if let Some(f) = args().nth(1) { if config.parsefile(f).is_err() { exit(1); } } let (port, daemonize) = (config.port, config.daemonize); let mut server = Server::new(config); { let mut db = server.ge...
identifier_body
main.rs
pub mod release; use std::env::args; use std::process::exit; use crate::release::*; use compat::getpid; use config::Config; use logger::{Level, Logger}; use networking::Server; fn main() { let mut config = Config::new(Logger::new(Level::Notice)); if let Some(f) = args().nth(1) { if config.parsefile(f...
let mut db = server.get_mut_db(); db.git_sha1 = GIT_SHA1; db.git_dirty = GIT_DIRTY; db.version = env!("CARGO_PKG_VERSION"); db.rustc_version = RUSTC_VERSION; } if!daemonize { println!("Port: {}", port); println!("PID: {}", getpid()); } server.run(...
random_line_split
main.rs
pub mod release; use std::env::args; use std::process::exit; use crate::release::*; use compat::getpid; use config::Config; use logger::{Level, Logger}; use networking::Server; fn
() { let mut config = Config::new(Logger::new(Level::Notice)); if let Some(f) = args().nth(1) { if config.parsefile(f).is_err() { exit(1); } } let (port, daemonize) = (config.port, config.daemonize); let mut server = Server::new(config); { let mut db = server...
main
identifier_name
portal.rs
// Copyright 2013-2014 Jeffery Olson // // Licensed under the 3-Clause BSD License, see LICENSE.txt // at the top-level of this repository. // This file may not be copied, modified, or distributed // except according to those terms. use uuid::Uuid; use world::TraversalDirection; use world::TraversalDirection::*; #[d...
b_zid: Uuid, bx: TraversalDirection) -> Portal { if ae == North && bx!= South { panic!("bad portal dirs a:{} b:{}", ae, bx); } if ae == South && bx!= North { panic!("bad portal dirs a:{} b:{}", ae, bx); } if ae == West && bx!= East { panic!("bad portal dirs a:{} b:{}", ae, bx); } ...
pub fn new(id: Uuid, a_zid: Uuid, ae: TraversalDirection,
random_line_split
portal.rs
// Copyright 2013-2014 Jeffery Olson // // Licensed under the 3-Clause BSD License, see LICENSE.txt // at the top-level of this repository. // This file may not be copied, modified, or distributed // except according to those terms. use uuid::Uuid; use world::TraversalDirection; use world::TraversalDirection::*; #[d...
pub fn info_from(&self, zid: Uuid) -> (Uuid, TraversalDirection) { if self.a_zid == zid { (self.b_zid, self.a_exit) } else if self.b_zid == zid { (self.a_zid, self.b_exit) } else { panic!("zid:{} isn't in this portal!", zid) } } }
{ if ae == North && bx != South { panic!("bad portal dirs a:{} b:{}", ae, bx); } if ae == South && bx != North { panic!("bad portal dirs a:{} b:{}", ae, bx); } if ae == West && bx != East { panic!("bad portal dirs a:{} b:{}", ae, bx); } if ae == East && bx != West { panic!("bad portal di...
identifier_body
portal.rs
// Copyright 2013-2014 Jeffery Olson // // Licensed under the 3-Clause BSD License, see LICENSE.txt // at the top-level of this repository. // This file may not be copied, modified, or distributed // except according to those terms. use uuid::Uuid; use world::TraversalDirection; use world::TraversalDirection::*; #[d...
if ae == South && bx!= North { panic!("bad portal dirs a:{} b:{}", ae, bx); } if ae == West && bx!= East { panic!("bad portal dirs a:{} b:{}", ae, bx); } if ae == East && bx!= West { panic!("bad portal dirs a:{} b:{}", ae, bx); } Portal { id: id, a_zid: a_zid, a_exit: ae, b_zid: b_zid, ...
{ panic!("bad portal dirs a:{} b:{}", ae, bx); }
conditional_block
portal.rs
// Copyright 2013-2014 Jeffery Olson // // Licensed under the 3-Clause BSD License, see LICENSE.txt // at the top-level of this repository. // This file may not be copied, modified, or distributed // except according to those terms. use uuid::Uuid; use world::TraversalDirection; use world::TraversalDirection::*; #[d...
(id: Uuid, a_zid: Uuid, ae: TraversalDirection, b_zid: Uuid, bx: TraversalDirection) -> Portal { if ae == North && bx!= South { panic!("bad portal dirs a:{} b:{}", ae, bx); } if ae == South && bx!= North { panic!("bad portal dirs a:{} b:{}", ae, bx); } if ae == West && bx!= East {...
new
identifier_name
lib.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.o...
// extern crate regex; extern crate syntax; extern crate regex; #[cfg(test)] extern crate hamcrest; pub mod builder; pub mod node; pub mod parser; #[path="../../src/hal/lpc17xx/platformtree.rs"] mod lpc17xx_pt; #[path="../../src/hal/tiva_c/platformtree.rs"] mod tiva_c_pt; #[path="../../src/drivers/drivers_pt.rs"] mo...
//! Platform tree operations crate #![feature(quote, rustc_private)]
random_line_split
lib.rs
#![doc(html_logo_url = "https://avatars0.githubusercontent.com/u/7853871?s=128", html_favicon_url = "https://avatars0.githubusercontent.com/u/7853871?s=256", html_root_url = "http://ironframework.io/core/iron")] #![cfg_attr(test, deny(warnings))] #![deny(missing_docs)] //! The main crate for Iron. //! //! ## Overview ...
//! writes and locking in the core framework. //! //! ## Hello World //! //! ```no_run //! extern crate iron; //! //! use iron::prelude::*; //! use iron::status; //! //! fn main() { //! Iron::new(|_: &mut Request| { //! Ok(Response::with((status::Ok, "Hello World!"))) //! }).http("localhost:3000").unwra...
//! approach to ownership in both single threaded and multi threaded contexts. //! //! Iron is highly concurrent and can scale horizontally on more machines behind a //! load balancer or by running more threads on a more powerful machine. Iron //! avoids the bottlenecks encountered in highly concurrent code by avoiding...
random_line_split
fromdb.rs
/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this
use rusqlite::Row; use crate::catalog::CatalogVersion; /// Trait to define loading from a database. pub trait FromDb: Sized { /// Read one element from a database Row obtained through a query /// build with the tables and columns provided. /// The version of the catalog allow selecting the proper variant....
file, You can obtain one at http://mozilla.org/MPL/2.0/. */
random_line_split
fromdb.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 rusqlite::Row; use crate::catalog::CatalogVersion; /// Trait to define loading from a database. pub trait FromD...
(_version: CatalogVersion) -> &'static str { "" } }
read_join_where
identifier_name
fromdb.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 rusqlite::Row; use crate::catalog::CatalogVersion; /// Trait to define loading from a database. pub trait FromD...
}
{ "" }
identifier_body
domtokenlist.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::attr::{Attr, AttrHelpers}; use dom::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::...
} } } } // https://dom.spec.whatwg.org/#stringification-behavior fn Stringifier(self) -> DOMString { let tokenlist = self.element.root().r().get_tokenlist_attribute(&self.local_name); str_join(&tokenlist, "\x20") } // check-tidy: no specs after t...
_ => { atoms.push(token); element.r().set_atomic_tokenlist_attribute(&self.local_name, atoms); Ok(true)
random_line_split
domtokenlist.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::attr::{Attr, AttrHelpers}; use dom::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::...
fn check_token_exceptions(self, token: &str) -> Fallible<Atom> { match token { "" => Err(Syntax), slice if slice.find(HTML_SPACE_CHARACTERS).is_some() => Err(InvalidCharacter), slice => Ok(Atom::from_slice(slice)) } } } // https://dom.spec.whatwg.org/#domto...
{ let element = self.element.root(); element.r().get_attribute(&ns!(""), &self.local_name) }
identifier_body
domtokenlist.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::attr::{Attr, AttrHelpers}; use dom::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::...
(self) -> u32 { self.attribute().map(|attr| { let attr = attr.r(); attr.value().tokens().map(|tokens| tokens.len()).unwrap_or(0) }).unwrap_or(0) as u32 } // https://dom.spec.whatwg.org/#dom-domtokenlist-item fn Item(self, index: u32) -> Option<DOMString> { se...
Length
identifier_name
query04.rs
use timely::order::TotalOrder; use timely::dataflow::*; use timely::dataflow::operators::probe::Handle as ProbeHandle; use differential_dataflow::operators::*; use differential_dataflow::lattice::Lattice; use {Arrangements, Experiment, Collections}; // -- $ID$ // -- TPC-H/TPC-R Order Priority Checking Query (Q4) // ...
// from // orders // where // o_orderdate >= date ':1' // and o_orderdate < date ':1' + interval '3' month // and exists ( // select // * // from // lineitem // where // l_orderkey = o_orderkey // and l_commitdate < l_receiptdate //...
// :o // select // o_orderpriority, // count(*) as order_count
random_line_split
query04.rs
use timely::order::TotalOrder; use timely::dataflow::*; use timely::dataflow::operators::probe::Handle as ProbeHandle; use differential_dataflow::operators::*; use differential_dataflow::lattice::Lattice; use {Arrangements, Experiment, Collections}; // -- $ID$ // -- TPC-H/TPC-R Order Priority Checking Query (Q4) // ...
{ let arrangements = arrangements.in_scope(scope, experiment); experiment .lineitem(scope) .flat_map(|l| if l.commit_date < l.receipt_date { Some((l.order_key, ())) } else { None }) .distinct_total() .join_core(&arrangements.order, |_k,&(),o| { if o.order_date >= ::t...
identifier_body
query04.rs
use timely::order::TotalOrder; use timely::dataflow::*; use timely::dataflow::operators::probe::Handle as ProbeHandle; use differential_dataflow::operators::*; use differential_dataflow::lattice::Lattice; use {Arrangements, Experiment, Collections}; // -- $ID$ // -- TPC-H/TPC-R Order Priority Checking Query (Q4) // ...
<G: Scope<Timestamp=usize>>( scope: &mut G, probe: &mut ProbeHandle<usize>, experiment: &mut Experiment, arrangements: &mut Arrangements, ) where G::Timestamp: Lattice+TotalOrder+Ord { let arrangements = arrangements.in_scope(scope, experiment); experiment .lineitem(scope) .fl...
query_arranged
identifier_name