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
test_enum.rs
// Copyright 2019 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. use bit_field::*; #[bitfield] #[derive(Debug, PartialEq)] enum TwoBits { Zero = 0b00, One = 0b01, Two = 0b10, Three = 0b11, } #[bitfi...
#[bitfield] struct Struct { prefix: BitField1, two_bits: TwoBits, three_bits: ThreeBits, suffix: BitField2, } #[test] fn test_enum() { let mut s = Struct::new(); assert_eq!(s.get(0, 8), 0b_0000_0000); assert_eq!(s.get_two_bits(), TwoBits::Zero); s.set_two_bits(TwoBits::Three); ass...
Two = 0b10, Three = 0b111, }
random_line_split
test_enum.rs
// Copyright 2019 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. use bit_field::*; #[bitfield] #[derive(Debug, PartialEq)] enum TwoBits { Zero = 0b00, One = 0b01, Two = 0b10, Three = 0b11, } #[bitfi...
() { let mut s = Struct::new(); assert_eq!(s.get(0, 8), 0b_0000_0000); assert_eq!(s.get_two_bits(), TwoBits::Zero); s.set_two_bits(TwoBits::Three); assert_eq!(s.get(0, 8), 0b_0000_0110); assert_eq!(s.get_two_bits(), TwoBits::Three); s.set(0, 8, 0b_1010_1010); // ^^ Tw...
test_enum
identifier_name
htmldataelement.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::HTMLDataElementBinding; use dom::bindings::codegen::Bindings::HTMLDataElemen...
use string_cache::Atom; #[dom_struct] pub struct HTMLDataElement { htmlelement: HTMLElement } impl HTMLDataElement { fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLDataElement { HTMLDataElement { htmleleme...
use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node;
random_line_split
htmldataelement.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::HTMLDataElementBinding; use dom::bindings::codegen::Bindings::HTMLDataElemen...
{ htmlelement: HTMLElement } impl HTMLDataElement { fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLDataElement { HTMLDataElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document) ...
HTMLDataElement
identifier_name
instr_movhpd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test]
#[test] fn movhpd_2() { run_test(&Instruction { mnemonic: Mnemonic::MOVHPD, operand1: Some(Direct(XMM6)), operand2: Some(IndirectDisplaced(RDI, 954220987, Some(OperandSize::Qword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, ...
fn movhpd_1() { run_test(&Instruction { mnemonic: Mnemonic::MOVHPD, operand1: Some(Direct(XMM4)), operand2: Some(IndirectScaledIndexed(EBX, EBX, Four, Some(OperandSize::Qword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[10...
random_line_split
instr_movhpd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test] fn
() { run_test(&Instruction { mnemonic: Mnemonic::MOVHPD, operand1: Some(Direct(XMM4)), operand2: Some(IndirectScaledIndexed(EBX, EBX, Four, Some(OperandSize::Qword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 22, ...
movhpd_1
identifier_name
instr_movhpd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test] fn movhpd_1()
#[test] fn movhpd_2() { run_test(&Instruction { mnemonic: Mnemonic::MOVHPD, operand1: Some(Direct(XMM6)), operand2: Some(IndirectDisplaced(RDI, 954220987, Some(OperandSize::Qword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }...
{ run_test(&Instruction { mnemonic: Mnemonic::MOVHPD, operand1: Some(Direct(XMM4)), operand2: Some(IndirectScaledIndexed(EBX, EBX, Four, Some(OperandSize::Qword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 22, 36,...
identifier_body
gl_context.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use glib::translate::*; use display::Display; use window::Window; use ffi; glib_wrapper! { ...
pub fn set_forward_compatible(&self, compatible: bool) { unsafe { ffi::gdk_gl_context_set_forward_compatible(self.to_glib_none().0, compatible.to_glib()) } } pub fn get_forward_compatible(&self) -> bool { unsafe { from_glib(ffi::gdk_gl_context_get_forward_compatible(self.to_glib_none().0)...
{ unsafe { from_glib(ffi::gdk_gl_context_get_debug_enabled(self.to_glib_none().0)) } }
identifier_body
gl_context.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use glib::translate::*; use display::Display; use window::Window; use ffi; glib_wrapper! { ...
(&self, enabled: bool) { unsafe { ffi::gdk_gl_context_set_debug_enabled(self.to_glib_none().0, enabled.to_glib()) } } pub fn get_debug_enabled(&self) -> bool { unsafe { from_glib(ffi::gdk_gl_context_get_debug_enabled(self.to_glib_none().0)) } } pub fn set_forward_compatible(&self, comp...
set_debug_enabled
identifier_name
gl_context.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use glib::translate::*; use display::Display; use window::Window; use ffi; glib_wrapper! { ...
pub fn get_current() -> Option<GLContext> { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::gdk_gl_context_get_current()) } } pub fn clear_current() { assert_initialized_main_thread!(); unsafe { ffi::gdk_gl_context_clear_current() } } }
pub fn make_current(&self) { unsafe { ffi::gdk_gl_context_make_current(self.to_glib_none().0) } }
random_line_split
main.rs
extern crate rand; extern crate sdl2; use std::error::Error; use std::fs::File; use std::io::prelude::*; use std::path::Path; use std::env; mod cpu; mod screen; mod keypad; mod sound; mod input; fn main()
let mut file = match File::open(&path) { Err(why) => panic!("couldn't open {}: {}", display, Error::description(&why)), Ok(file) => file, }; let mut buffer = Vec::new(); let _ = file.read_to_end(&mut buffer); println!("\"{}\" read successfully", display); //Create the window ...
{ let sdl_context = sdl2::init().expect("Failed to init SDL2"); let mut event_pump = sdl_context.event_pump().expect("Failed to init SDL2 event_pump"); let video_subsystem = sdl_context.video().expect("Failed to init SDL2 video"); let audio_subsystem = sdl_context.audio().expect("Failed to init SDL2 aud...
identifier_body
main.rs
extern crate rand; extern crate sdl2; use std::error::Error; use std::fs::File; use std::io::prelude::*; use std::path::Path; use std::env; mod cpu; mod screen; mod keypad; mod sound; mod input; fn
() { let sdl_context = sdl2::init().expect("Failed to init SDL2"); let mut event_pump = sdl_context.event_pump().expect("Failed to init SDL2 event_pump"); let video_subsystem = sdl_context.video().expect("Failed to init SDL2 video"); let audio_subsystem = sdl_context.audio().expect("Failed to init SDL2 ...
main
identifier_name
main.rs
extern crate rand; extern crate sdl2; use std::error::Error; use std::fs::File; use std::io::prelude::*; use std::path::Path; use std::env; mod cpu; mod screen; mod keypad; mod sound; mod input; fn main() { let sdl_context = sdl2::init().expect("Failed to init SDL2"); let mut event_pump = sdl_context.event_p...
sound.set_state(cpu.get_sound_state()); } }
{ last_tick = now; cpu.draw(&mut renderer); cpu.tick_timers(); }
conditional_block
main.rs
extern crate rand; extern crate sdl2; use std::error::Error; use std::fs::File; use std::io::prelude::*; use std::path::Path; use std::env; mod cpu; mod screen; mod keypad; mod sound; mod input; fn main() { let sdl_context = sdl2::init().expect("Failed to init SDL2"); let mut event_pump = sdl_context.event_p...
} let path = Path::new(&rom_file_name); let display = path.display(); let mut file = match File::open(&path) { Err(why) => panic!("couldn't open {}: {}", display, Error::description(&why)), Ok(file) => file, }; let mut buffer = Vec::new(); let _ = file.read_to_end(&mut buffer...
return; }
random_line_split
class-methods-cross-crate.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// option. This file may not be copied, modified, or distributed // except according to those terms. // aux-build:cci_class_3.rs // pretty-expanded FIXME #23616 extern crate cci_class_3; use cci_class_3::kitties::cat; pub fn main() { let mut nyan : cat = cat(52, 99); let kitty = cat(1000, 2); assert_eq!(...
// 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
random_line_split
class-methods-cross-crate.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...
{ let mut nyan : cat = cat(52, 99); let kitty = cat(1000, 2); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); nyan.speak(); assert_eq!(nyan.meow_count(), 53); }
identifier_body
class-methods-cross-crate.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...
() { let mut nyan : cat = cat(52, 99); let kitty = cat(1000, 2); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); nyan.speak(); assert_eq!(nyan.meow_count(), 53); }
main
identifier_name
main.rs
// // Copyright 2021 The Project Oak Authors // // 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 o...
else { b"b" }; let request = Request { body: body.to_vec(), }; client .invoke(request) .await .context("Could not invoke Oak Functions")?; } Ok(()) }
{ b"a" }
conditional_block
main.rs
// // Copyright 2021 The Project Oak Authors // // 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 o...
Ok(()) }
random_line_split
main.rs
// // Copyright 2021 The Project Oak Authors // // 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 o...
{ #[clap( long, help = "URI of the Oak Functions application to connect to", default_value = "http://localhost:8080" )] uri: String, } #[tokio::main] async fn main() -> anyhow::Result<()> { let opt = Opt::parse(); let mut client = Client::new(&opt.uri, |_config| Ok(())) ...
Opt
identifier_name
htmlaudioelement.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::HTMLAudioElementBinding; use dom::bindings::codegen::InheritTypes::HTMLAudio...
#[allow(unrooted_must_root)] pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLAudioElement> { let element = HTMLAudioElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLAudioElementBinding::Wr...
{ HTMLAudioElement { htmlmediaelement: HTMLMediaElement::new_inherited(HTMLMediaElementTypeId::HTMLAudioElement, localName, prefix, document) } }
identifier_body
htmlaudioelement.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::HTMLAudioElementBinding; use dom::bindings::codegen::InheritTypes::HTMLAudio...
#[allow(unrooted_must_root)] pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLAudioElement> { let element = HTMLAudioElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLAudioElementBinding::Wrap...
HTMLAudioElement { htmlmediaelement: HTMLMediaElement::new_inherited(HTMLMediaElementTypeId::HTMLAudioElement, localName, prefix, document) } }
random_line_split
htmlaudioelement.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::HTMLAudioElementBinding; use dom::bindings::codegen::InheritTypes::HTMLAudio...
(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLAudioElement { HTMLAudioElement { htmlmediaelement: HTMLMediaElement::new_inherited(HTMLMediaElementTypeId::HTMLAudioElement, localName, prefix, document) } } #[allow(unrooted_must_root)] pub fn ...
new_inherited
identifier_name
attrs-with-no-formal-in-generics-3.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 ...
<'a, 'b>(&'a u32, &'b u32); fn hof_lt<Q>(_: Q) where Q: for <#[rustc_1] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32 //~^ ERROR trailing attribute after lifetime parameters { } fn main() { }
RefIntPair
identifier_name
attrs-with-no-formal-in-generics-3.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 ...
}
random_line_split
font_chooser_dialog.rs
// This file was generated by gir (5c017c9) from gir-files (71d73f0) // DO NOT EDIT use Bin; use Container; use Dialog; use FontChooser; use Widget; use Window; use ffi; use glib::object::Downcast; use glib::object::IsA; use glib::translate::*; glib_wrapper! { pub struct FontChooserDialog(Object<ffi::GtkFontChoos...
<'a, 'b, P: Into<Option<&'a str>>, Q: IsA<Window> + 'b, R: Into<Option<&'b Q>>>(title: P, parent: R) -> FontChooserDialog { assert_initialized_main_thread!(); let title = title.into(); let title = title.to_glib_none(); let parent = parent.into(); let parent = parent.to_glib_none(...
new
identifier_name
font_chooser_dialog.rs
// This file was generated by gir (5c017c9) from gir-files (71d73f0) // DO NOT EDIT use Bin; use Container; use Dialog; use FontChooser; use Widget; use Window; use ffi; use glib::object::Downcast; use glib::object::IsA; use glib::translate::*; glib_wrapper! { pub struct FontChooserDialog(Object<ffi::GtkFontChoos...
let parent = parent.to_glib_none(); unsafe { Widget::from_glib_none(ffi::gtk_font_chooser_dialog_new(title.0, parent.0)).downcast_unchecked() } } }
pub fn new<'a, 'b, P: Into<Option<&'a str>>, Q: IsA<Window> + 'b, R: Into<Option<&'b Q>>>(title: P, parent: R) -> FontChooserDialog { assert_initialized_main_thread!(); let title = title.into(); let title = title.to_glib_none(); let parent = parent.into();
random_line_split
font_chooser_dialog.rs
// This file was generated by gir (5c017c9) from gir-files (71d73f0) // DO NOT EDIT use Bin; use Container; use Dialog; use FontChooser; use Widget; use Window; use ffi; use glib::object::Downcast; use glib::object::IsA; use glib::translate::*; glib_wrapper! { pub struct FontChooserDialog(Object<ffi::GtkFontChoos...
}
{ assert_initialized_main_thread!(); let title = title.into(); let title = title.to_glib_none(); let parent = parent.into(); let parent = parent.to_glib_none(); unsafe { Widget::from_glib_none(ffi::gtk_font_chooser_dialog_new(title.0, parent.0)).downcast_unche...
identifier_body
containers.rs
// Copyright 2017 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
impl ContainersReq { /// Consumes the object and returns the FFI counterpart. /// /// You're now responsible for freeing the subobjects memory once you're /// done. pub fn into_repr_c(self) -> Result<ffi::ContainersReq, IpcError> { let ContainersReq { app, containers } = self; let c...
pub containers: HashMap<String, ContainerPermissions>, }
random_line_split
containers.rs
// Copyright 2017 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
{ /// Exchange info pub app: AppExchangeInfo, /// Requested containers pub containers: HashMap<String, ContainerPermissions>, } impl ContainersReq { /// Consumes the object and returns the FFI counterpart. /// /// You're now responsible for freeing the subobjects memory once you're ///...
ContainersReq
identifier_name
containers.rs
// Copyright 2017 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
}
{ Ok(ContainersReq { app: AppExchangeInfo::clone_from_repr_c(&(*repr_c).app)?, containers: containers_from_repr_c((*repr_c).containers, (*repr_c).containers_len)?, }) }
identifier_body
reference.rs
use super::*; impl<'graph, G: DirectedGraph> DirectedGraph for &'graph G { type Node = G::Node; } impl<'graph, G: WithNumNodes> WithNumNodes for &'graph G { fn num_nodes(&self) -> usize { (**self).num_nodes() } } impl<'graph, G: WithStartNode> WithStartNode for &'graph G { fn start_node(&self...
} impl<'graph, G: WithSuccessors> WithSuccessors for &'graph G { fn successors(&self, node: Self::Node) -> <Self as GraphSuccessors<'_>>::Iter { (**self).successors(node) } } impl<'graph, G: WithPredecessors> WithPredecessors for &'graph G { fn predecessors(&self, node: Self::Node) -> <Self as Gr...
{ (**self).start_node() }
identifier_body
reference.rs
use super::*; impl<'graph, G: DirectedGraph> DirectedGraph for &'graph G { type Node = G::Node; } impl<'graph, G: WithNumNodes> WithNumNodes for &'graph G { fn num_nodes(&self) -> usize { (**self).num_nodes() } } impl<'graph, G: WithStartNode> WithStartNode for &'graph G { fn start_node(&self...
(&self, node: Self::Node) -> <Self as GraphSuccessors<'_>>::Iter { (**self).successors(node) } } impl<'graph, G: WithPredecessors> WithPredecessors for &'graph G { fn predecessors(&self, node: Self::Node) -> <Self as GraphPredecessors<'_>>::Iter { (**self).predecessors(node) } } impl<'iter...
successors
identifier_name
reference.rs
use super::*; impl<'graph, G: DirectedGraph> DirectedGraph for &'graph G { type Node = G::Node; } impl<'graph, G: WithNumNodes> WithNumNodes for &'graph G { fn num_nodes(&self) -> usize { (**self).num_nodes() } } impl<'graph, G: WithStartNode> WithStartNode for &'graph G { fn start_node(&self...
} impl<'iter, 'graph, G: WithPredecessors> GraphPredecessors<'iter> for &'graph G { type Item = G::Node; type Iter = <G as GraphPredecessors<'iter>>::Iter; } impl<'iter, 'graph, G: WithSuccessors> GraphSuccessors<'iter> for &'graph G { type Item = G::Node; type Iter = <G as GraphSuccessors<'iter>>::It...
impl<'graph, G: WithPredecessors> WithPredecessors for &'graph G { fn predecessors(&self, node: Self::Node) -> <Self as GraphPredecessors<'_>>::Iter { (**self).predecessors(node) }
random_line_split
test_moqt.rs
use crate::lib_configs::{ global_config, MOQT_INSTALL_DIR_ENV_VAR_NAME, MOQT_TEMPLATE_DIR_ENV_VAR_NAME, }; use ritual::cli::{self, Options}; use ritual_common::cpp_lib_builder::{BuildType, CppLibBuilder}; use ritual_common::env_var_names; use ritual_common::errors::{FancyUnwrap, Result}; use ritual_common::file_uti...
else { TempTestDir::System(::tempdir::TempDir::new(name).unwrap()) } } pub fn path(&self) -> &Path { match self { TempTestDir::System(dir) => dir.path(), TempTestDir::Custom(path) => path, } } } fn build_moqt() -> Result<TempTestDir> { let c...
{ let path = PathBuf::from(value); create_dir_all(&path).unwrap(); let path = canonicalize(path).unwrap().join(name); create_dir_all(&path).unwrap(); TempTestDir::Custom(path) }
conditional_block
test_moqt.rs
use crate::lib_configs::{ global_config, MOQT_INSTALL_DIR_ENV_VAR_NAME, MOQT_TEMPLATE_DIR_ENV_VAR_NAME, }; use ritual::cli::{self, Options}; use ritual_common::cpp_lib_builder::{BuildType, CppLibBuilder}; use ritual_common::env_var_names; use ritual_common::errors::{FancyUnwrap, Result}; use ritual_common::file_uti...
{ let temp_dir = build_moqt().fancy_unwrap(); let workspace = temp_dir.path().join("workspace"); create_dir_all(&workspace).unwrap(); cli::run( Options { workspace, local_paths: Some(true), crates: vec!["moqt_core".into(), "moqt_gui".into()], oper...
identifier_body
test_moqt.rs
use crate::lib_configs::{ global_config, MOQT_INSTALL_DIR_ENV_VAR_NAME, MOQT_TEMPLATE_DIR_ENV_VAR_NAME, }; use ritual::cli::{self, Options}; use ritual_common::cpp_lib_builder::{BuildType, CppLibBuilder}; use ritual_common::env_var_names; use ritual_common::errors::{FancyUnwrap, Result}; use ritual_common::file_uti...
() -> Result<TempTestDir> { let cpp_lib_source_dir = repo_dir_path("qt_ritual/test_assets/moqt")?; let temp_dir = TempTestDir::new("test_full_run"); let build_dir = temp_dir.path().join("build"); let install_dir = temp_dir.path().join("install"); let template_dir = temp_dir.path().join("template");...
build_moqt
identifier_name
test_moqt.rs
use crate::lib_configs::{ global_config, MOQT_INSTALL_DIR_ENV_VAR_NAME, MOQT_TEMPLATE_DIR_ENV_VAR_NAME, }; use ritual::cli::{self, Options}; use ritual_common::cpp_lib_builder::{BuildType, CppLibBuilder}; use ritual_common::env_var_names; use ritual_common::errors::{FancyUnwrap, Result}; use ritual_common::file_uti...
) .fancy_unwrap(); }
random_line_split
qselect.rs
use std::cmp::Ordering; // The threshold below which qselect_inplace_by() should just sort the slice. const SORT_THRESH: usize = 6; /// Use the Quickselect algorithm to select the `k`th smallest /// element from `data`. /// /// Does not modify `data`. Allocates an additional vector for scratch space; see `qselect_in...
/// Use the Quickselect algorithm to select the `k`th smallest element from `data`. As part of the /// algorithm, `k` is moved to its final sorted position and the rest of the array is (at least) partially /// sorted. /// /// For a version that uses extra space but does not reorder the slice, use `qselect`. /// /// #...
{ let len = data.len(); assert!(k < len, "Called qselect with k = {} and data length: {}", k, len); let mut refs: Vec<_> = data.iter().collect(); *qselect_inplace_by(&mut refs, k, |l, r| ord_fn(l, r)) }
identifier_body
qselect.rs
use std::cmp::Ordering; // The threshold below which qselect_inplace_by() should just sort the slice. const SORT_THRESH: usize = 6; /// Use the Quickselect algorithm to select the `k`th smallest /// element from `data`. /// /// Does not modify `data`. Allocates an additional vector for scratch space; see `qselect_in...
else if k < pivot_idx { qselect_inplace_by(&mut data[..pivot_idx], k, ord_fn) } else { qselect_inplace_by(&mut data[pivot_idx + 1..], k - pivot_idx - 1, ord_fn) } } /// Given an ordering function, pick an arbitrary pivot and partition the slice, returning the pivot. fn partition_by<T, F: FnMut...
{ &mut data[pivot_idx] }
conditional_block
qselect.rs
use std::cmp::Ordering; // The threshold below which qselect_inplace_by() should just sort the slice. const SORT_THRESH: usize = 6; /// Use the Quickselect algorithm to select the `k`th smallest /// element from `data`. /// /// Does not modify `data`. Allocates an additional vector for scratch space; see `qselect_in...
<T, F: FnMut(&T, &T) -> Ordering>(data: &mut [T], mut ord_fn: F) -> usize { let len = data.len(); let pivot_idx = { let first = (&data[0], 0); let mid = (&data[len / 2], len / 2); let last = (&data[len - 1], len - 1); super::median_of_3_by(&first, &mid, &last, |left, right| ord...
partition_by
identifier_name
qselect.rs
use std::cmp::Ordering; // The threshold below which qselect_inplace_by() should just sort the slice. const SORT_THRESH: usize = 6; /// Use the Quickselect algorithm to select the `k`th smallest /// element from `data`. /// /// Does not modify `data`. Allocates an additional vector for scratch space; see `qselect_in...
/// sorted. /// /// For a version that uses extra space but does not reorder the slice, use `qselect_by`. /// /// ##Panics /// If `k` is greater than `data.len()`. pub fn qselect_inplace_by<T, F: FnMut(&T, &T) -> Ordering>(data: &mut [T], k: usize, mut ord_fn: F) -> &mut T { let len = data.len(); assert!(k < l...
random_line_split
service.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity 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 lat...
path.push("restoration"); let manifest = ManifestData { version: 2, state_hashes: vec![], block_hashes: vec![], block_number: 0, block_hash: Default::default(), state_root: Default::default(), }; service.init_restore(manifest.clone(), true).unwrap(); assert!(path.exists()); service.abort_restore();...
let service = Service::new(service_params).unwrap();
random_line_split
service.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity 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 lat...
(&self, _new_db: &str) -> Result<(), ::error::Error> { Ok(()) } } #[test] fn restored_is_equivalent() { const NUM_BLOCKS: u32 = 400; const TX_PER: usize = 5; let gas_prices = vec![1.into(), 2.into(), 3.into(), 999.into()]; let client = generate_dummy_client_with_spec_and_data(Spec::new_null, NUM_BLOCKS, TX_PE...
restore_db
identifier_name
generic-no-mangle.rs
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![deny(no_mangle_generic_items)] #[no_mangle] pub fn foo<T>() {} //~ ERROR functions g...
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
random_line_split
generic-no-mangle.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(x: &i32) -> &i32 { x } #[no_mangle] pub fn qux<'a>(x: &'a i32) -> &i32 { x } fn main() {}
baz
identifier_name
generic-no-mangle.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
//~ ERROR functions generic over types must be mangled #[no_mangle] pub fn baz(x: &i32) -> &i32 { x } #[no_mangle] pub fn qux<'a>(x: &'a i32) -> &i32 { x } fn main() {}
{}
identifier_body
hir_wf_check.rs
use crate::collect::ItemCtxt; use rustc_hir as hir; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::HirId; use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::TraitEngine; use rustc_infer::traits::{ObligationCause, WellFormedLoc}; use rustc_middle::ty::query::Providers; use rus...
// Higher ranked regions are complicated. // To make matters worse, the HIR WF check can instantiate them // outside of a `Binder`, due to the way we (ab)use // `ItemCtxt::to_ty`. To make things simpler, we just erase all // of them, regardless of depth. At worse, this will give // us an inaccurate span for an error me...
struct EraseAllBoundRegions<'tcx> { tcx: TyCtxt<'tcx>, }
random_line_split
hir_wf_check.rs
use crate::collect::ItemCtxt; use rustc_hir as hir; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::HirId; use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::TraitEngine; use rustc_infer::traits::{ObligationCause, WellFormedLoc}; use rustc_middle::ty::query::Providers; use rus...
<'tcx> { tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tcx>, cause: Option<ObligationCause<'tcx>>, cause_depth: usize, icx: ItemCtxt<'tcx>, hir_id: HirId, param_env: ty::ParamEnv<'tcx>, depth: usize, } impl<'tcx> Visitor<'tcx> for HirWfCheck<'tcx> ...
HirWfCheck
identifier_name
customevent.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::codegen::Bindings::CustomEventBinding; use crate::dom::bindings::codegen::Bindings::Cust...
#[allow(unsafe_code)] // https://dom.spec.whatwg.org/#dom-customevent-initcustomevent unsafe fn InitCustomEvent( &self, _cx: *mut JSContext, type_: DOMString, can_bubble: bool, cancelable: bool, detail: HandleValue, ) { self.init_custom_event(Ato...
{ self.detail.get() }
identifier_body
customevent.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::codegen::Bindings::CustomEventBinding; use crate::dom::bindings::codegen::Bindings::Cust...
cancelable: bool, detail: HandleValue, ) { let event = self.upcast::<Event>(); if event.dispatching() { return; } self.detail.set(detail.get()); event.init_event(type_, can_bubble, cancelable); } } impl CustomEventMethods for CustomEvent { ...
type_: Atom, can_bubble: bool,
random_line_split
customevent.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::codegen::Bindings::CustomEventBinding; use crate::dom::bindings::codegen::Bindings::Cust...
(&self, _cx: *mut JSContext) -> JSVal { self.detail.get() } #[allow(unsafe_code)] // https://dom.spec.whatwg.org/#dom-customevent-initcustomevent unsafe fn InitCustomEvent( &self, _cx: *mut JSContext, type_: DOMString, can_bubble: bool, cancelable: bool, ...
Detail
identifier_name
customevent.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::codegen::Bindings::CustomEventBinding; use crate::dom::bindings::codegen::Bindings::Cust...
self.detail.set(detail.get()); event.init_event(type_, can_bubble, cancelable); } } impl CustomEventMethods for CustomEvent { #[allow(unsafe_code)] // https://dom.spec.whatwg.org/#dom-customevent-detail unsafe fn Detail(&self, _cx: *mut JSContext) -> JSVal { self.detail.get() ...
{ return; }
conditional_block
window.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 glutin; use logs::ShellLog; use platform::View; use servo::EventLoopWaker; use state::{BrowserState, ChangeTyp...
windows .get_mut(&self.id) .unwrap() .window_events .push(WindowEvent::UrlbarFocusChanged(false)); } } } impl WindowMethods for Window { fn render(&self, diff: Vec<ChangeType>, state: &WindowState) { let idx = state ...
win.window_events .push(WindowEvent::DoCommand(WindowCommand::Load(input))); } None => {} }
random_line_split
window.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 glutin; use logs::ShellLog; use platform::View; use servo::EventLoopWaker; use state::{BrowserState, ChangeTyp...
(&self, state: &BrowserState) { if state.urlbar_focused { let mut windows = self.windows.borrow_mut(); let url = format!("{}", state.url.as_ref().map_or("", |t| t.as_str())); match tinyfiledialogs::input_box("Search or type URL", "Search or type URL", &url) { ...
render_urlbar
identifier_name
window.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 glutin; use logs::ShellLog; use platform::View; use servo::EventLoopWaker; use state::{BrowserState, ChangeTyp...
fn new_event_loop_waker(&self) -> Box<EventLoopWaker> { let mut windows = self.windows.borrow_mut(); windows .get_mut(&self.id) .unwrap() .event_loop_waker .clone() } fn get_events(&self) -> Vec<WindowEvent> { let mut windows = self.wind...
{ Ok(Rc::new(View::new(self.id, self.windows.clone()))) }
identifier_body
namednodemap.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; use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use dom::bindings::code...
(&self, attr: &Attr) -> Fallible<Option<Root<Attr>>> { self.owner.SetAttributeNode(attr) } // https://dom.spec.whatwg.org/#dom-namednodemap-setnameditemns fn SetNamedItemNS(&self, attr: &Attr) -> Fallible<Option<Root<Attr>>> { self.SetNamedItem(attr) } // https://dom.spec.whatwg.or...
SetNamedItem
identifier_name
namednodemap.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; use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use dom::bindings::code...
// https://dom.spec.whatwg.org/#dom-namednodemap-removenameditemns fn RemoveNamedItemNS(&self, namespace: Option<DOMString>, local_name: DOMString) -> Fallible<Root<Attr>> { let ns = namespace_from_domstring(namespace); self.owner.remove_attribute(&ns, &LocalName::from(lo...
{ let name = self.owner.parsed_name(name); self.owner.remove_attribute_by_name(&name).ok_or(Error::NotFound) }
identifier_body
namednodemap.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; use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use dom::bindings::code...
impl NamedNodeMapMethods for NamedNodeMap { // https://dom.spec.whatwg.org/#dom-namednodemap-length fn Length(&self) -> u32 { self.owner.attrs().len() as u32 } // https://dom.spec.whatwg.org/#dom-namednodemap-item fn Item(&self, index: u32) -> Option<Root<Attr>> { self.owner.attrs(...
window, NamedNodeMapBinding::Wrap) } }
random_line_split
namednodemap.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; use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use dom::bindings::code...
if!names.iter().any(|name| &*name == s) { names.push(DOMString::from(s)); } } names } }
{ continue }
conditional_block
htmlmetaelement.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::HTMLMetaElementBinding; use dom::bindings::codegen::Bindings::HTMLMetaElemen...
{ htmlelement: HTMLElement, } impl HTMLMetaElementDerived for EventTarget { fn is_htmlmetaelement(&self) -> bool { *self.type_id() == EventTargetTypeId::Node( NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLMetaElement))) } } impl HTMLMetaElement ...
HTMLMetaElement
identifier_name
htmlmetaelement.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::HTMLMetaElementBinding; use dom::bindings::codegen::Bindings::HTMLMetaElemen...
#[dom_struct] pub struct HTMLMetaElement { htmlelement: HTMLElement, } impl HTMLMetaElementDerived for EventTarget { fn is_htmlmetaelement(&self) -> bool { *self.type_id() == EventTargetTypeId::Node( NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLMetaE...
use util::str::DOMString;
random_line_split
htmlmetaelement.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::HTMLMetaElementBinding; use dom::bindings::codegen::Bindings::HTMLMetaElemen...
#[allow(unrooted_must_root)] pub fn new(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> Root<HTMLMetaElement> { let element = HTMLMetaElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLMetaEl...
{ HTMLMetaElement { htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLMetaElement, localName, prefix, document) } }
identifier_body
decodable.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...
vec!(), true)))) }, explicit_self: None, args: vec!(Ptr(box Literal(Path::new_local("__D")), Borrowed(None, MutMutable))), ret_ty: Literal(Path::new_( pathvec_std!(cx, core...
{ if !cx.use_std { // FIXME(#21880): lift this requirement. cx.span_err(span, "this trait cannot be derived with #![no_std]"); return; } let trait_def = TraitDef { span: span, attributes: Vec::new(), path: Path::new_(vec!(krate, "Decodable"), None, vec!(), tr...
identifier_body
decodable.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...
path: Path::new_(vec!(krate, "Decodable"), None, vec!(), true), additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), methods: vec!( MethodDef { name: "decode", generics: LifetimeBounds { lifetimes: Vec::new(), ...
span: span, attributes: Vec::new(),
random_line_split
decodable.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...
<F>(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Item, push: F) where F: FnOnce(P<Item>), { expand_deriving_decodable_imp(cx, span, mi...
expand_deriving_rustc_decodable
identifier_name
build.rs
use std::{env, fs}; use std::path::{Path, PathBuf}; extern crate gcc; #[cfg(unix)] const OS_DEPENDENT: &'static [&'static str] = &["glslang", "OSDependent", "Linux"]; #[cfg(windows)]
const SEARCH_DIRS: &'static [&'static [&'static str]] = &[ &["glslang"], &["glslang", "gen"], &["glslang", "GenericCodeGen"], &["glslang", "Include"], &["glslang", "MachineIndependent"], &["glslang", "MachineIndependent", "preprocessor"], &["glslang", "Public"], OS_DEPENDENT, &["OGLC...
const OS_DEPENDENT: &'static [&'static str] = &["glslang", "OSDependent", "Windows"];
random_line_split
build.rs
use std::{env, fs}; use std::path::{Path, PathBuf}; extern crate gcc; #[cfg(unix)] const OS_DEPENDENT: &'static [&'static str] = &["glslang", "OSDependent", "Linux"]; #[cfg(windows)] const OS_DEPENDENT: &'static [&'static str] = &["glslang", "OSDependent", "Windows"]; const SEARCH_DIRS: &'static [&'static [&'static...
} if ok { Some(path) } else { None } }) { sources.push(file) } } sources } fn resolve_search_dirs<P: AsRef<Path>>(root: &P) -> Vec<PathBuf> { SEARCH_DIRS.iter().map(|dir| { let mut buf = root.as_ref().to_owned(); for component in *dir ...
{ ok = true; }
conditional_block
build.rs
use std::{env, fs}; use std::path::{Path, PathBuf}; extern crate gcc; #[cfg(unix)] const OS_DEPENDENT: &'static [&'static str] = &["glslang", "OSDependent", "Linux"]; #[cfg(windows)] const OS_DEPENDENT: &'static [&'static str] = &["glslang", "OSDependent", "Windows"]; const SEARCH_DIRS: &'static [&'static [&'static...
<P: AsRef<Path>>(root: &P) -> Vec<PathBuf> { let mut sources = Vec::new(); for search_dir in resolve_search_dirs(root) { for file in fs::read_dir(search_dir).unwrap().filter_map(|e| { let path = e.unwrap().path(); let mut ok = false; if let Some(ext) = path.extens...
find_sources
identifier_name
build.rs
use std::{env, fs}; use std::path::{Path, PathBuf}; extern crate gcc; #[cfg(unix)] const OS_DEPENDENT: &'static [&'static str] = &["glslang", "OSDependent", "Linux"]; #[cfg(windows)] const OS_DEPENDENT: &'static [&'static str] = &["glslang", "OSDependent", "Windows"]; const SEARCH_DIRS: &'static [&'static [&'static...
} sources } fn resolve_search_dirs<P: AsRef<Path>>(root: &P) -> Vec<PathBuf> { SEARCH_DIRS.iter().map(|dir| { let mut buf = root.as_ref().to_owned(); for component in *dir { buf.push(component) } buf }).collect() } fn is_file<P: AsRef<Path>>(path: &P) ->...
{ let mut sources = Vec::new(); for search_dir in resolve_search_dirs(root) { for file in fs::read_dir(search_dir).unwrap().filter_map(|e| { let path = e.unwrap().path(); let mut ok = false; if let Some(ext) = path.extension() { if is_file(&path) &...
identifier_body
polynomials.rs
, InputStrategy: Fn(i64, i64, Range, Range, Metadata) -> i64, MetadataGenerator: Fn(Range) -> Metadata, MetadataTransformer: Fn(Metadata, Range, Range) -> Metadata, >( terms: &[Range], min_only: bool, max_only: bool, input_1: i64, input_2: i64, value_1: Range, value_2: Range, value_1_metadata: Met...
(terms: &[Range], input: i64) -> Range { let mut factor = Range::exactly(1); let mut result = Range::exactly(0); for term in terms.iter() { result = result + (term * factor); factor = factor * input; } result } pub fn multiply_polynomials(terms_0: &[Range], terms_1: &[Range]) -> Vec<Range> { (0..te...
evaluate
identifier_name
polynomials.rs
Copy, InputStrategy: Fn(i64, i64, Range, Range, Metadata) -> i64, MetadataGenerator: Fn(Range) -> Metadata, MetadataTransformer: Fn(Metadata, Range, Range) -> Metadata, >( terms: &[Range], min_only: bool, max_only: bool, input_1: i64, input_2: i64, value_1: Range, value_2: Range, value_1_metadata...
} fn find_root_search_default( terms: &[Range], min_only: bool, max_only: bool, input_1: i64, input_2: i64, value_1: Range, value_2: Range, ) -> (i64, i64) { let floating = |whatever: Range| (whatever.internal_min() as f64) * (2f64.powi(whatever.exponent() as i32)); let relaxed_result = find_root...
( if value_1 > 0 { input_1 } else { input_2 }, result_for_other, ) }
random_line_split
polynomials.rs
else { results.push(result); } } } // printlnerr!("My results: {:?}", results); return results; // if result_0.max >= result_1.min { // vec![Range { // min: result_0.min, // max: result_1.max, // exponent: 0, // }] // } else { // vec![result_0, result_1] // } } fn find_root_...
{ results.insert(0, result); }
conditional_block
polynomials.rs
, InputStrategy: Fn(i64, i64, Range, Range, Metadata) -> i64, MetadataGenerator: Fn(Range) -> Metadata, MetadataTransformer: Fn(Metadata, Range, Range) -> Metadata, >( terms: &[Range], min_only: bool, max_only: bool, input_1: i64, input_2: i64, value_1: Range, value_2: Range, value_1_metadata: Met...
} input }, &floating, &|fa, _, _| { // refer to "A Family of Regula Falsi Methods", Galdino // this method is written down as generally slightly the best in number of function evaluations, // but it profiled slightly worse, probably just because it uses more operations. /...
{ let floating = |whatever: Range| (whatever.internal_min() as f64) * (2f64.powi(whatever.exponent() as i32)); let relaxed_result = find_root_search( terms, min_only, max_only, input_1, input_2, value_1, value_2, floating(value_1), &|input_1, input_2, _, value_2, value_1_meta...
identifier_body
match-tag.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 ...
(c: color) -> isize { let mut x: isize; match c { color::rgb(r, _, _) => { x = r; } color::rgba(_, _, _, a) => { x = a; } color::hsl(_, s, _) => { x = s; } } return x; } pub fn main() { let gray: color = color::rgb(127, 127, 127); let clear: color = color::rgba(50, 150, 250, 0...
process
identifier_name
match-tag.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 ...
color::hsl(_, s, _) => { x = s; } } return x; } pub fn main() { let gray: color = color::rgb(127, 127, 127); let clear: color = color::rgba(50, 150, 250, 0); let red: color = color::hsl(0, 255, 255); assert_eq!(process(gray), 127); assert_eq!(process(clear), 0); assert_eq!(proces...
{ x = a; }
conditional_block
match-tag.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let gray: color = color::rgb(127, 127, 127); let clear: color = color::rgba(50, 150, 250, 0); let red: color = color::hsl(0, 255, 255); assert_eq!(process(gray), 127); assert_eq!(process(clear), 0); assert_eq!(process(red), 255); }
identifier_body
joiner.rs
use std::os; use std::io::File; use std::str; fn main() { let args: ~[~str] = os::args(); if args.len()!= 3 { println!("Usage: {:s} <inputfile>", args[0]); } else { let tempArg = &args; let fname1 = &tempArg[1]; let fname2 = &tempArg[2]; let path1 = Path::new(fname1.clone()); let pat...
let msg2_bytes: ~[u8] = msg2.read_to_end(); join(msg1_bytes, msg2_bytes); }, (_, _) => fail!("Error opening message file") } } } fn xor(a: &[u8], b: &[u8]) -> ~[u8] { let mut ret = ~[]; for i in range(0, a.len()) { ret.push(a[i] ^ b[i]); } ret } fn join(msg1_byt...
random_line_split
joiner.rs
use std::os; use std::io::File; use std::str; fn main()
}, (_, _) => fail!("Error opening message file") } } } fn xor(a: &[u8], b: &[u8]) -> ~[u8] { let mut ret = ~[]; for i in range(0, a.len()) { ret.push(a[i] ^ b[i]); } ret } fn join(msg1_bytes: &[u8], msg2_bytes: &[u8]) { let decrypted_bytes = xor(msg1_bytes, msg2_bytes); let...
{ let args: ~[~str] = os::args(); if args.len() != 3 { println!("Usage: {:s} <inputfile>", args[0]); } else { let tempArg = &args; let fname1 = &tempArg[1]; let fname2 = &tempArg[2]; let path1 = Path::new(fname1.clone()); let path2 = Path::new(fname2.clone()); let msg_file1 = File:...
identifier_body
joiner.rs
use std::os; use std::io::File; use std::str; fn main() { let args: ~[~str] = os::args(); if args.len()!= 3 { println!("Usage: {:s} <inputfile>", args[0]); } else { let tempArg = &args; let fname1 = &tempArg[1]; let fname2 = &tempArg[2]; let path1 = Path::new(fname1.clone()); let pat...
(a: &[u8], b: &[u8]) -> ~[u8] { let mut ret = ~[]; for i in range(0, a.len()) { ret.push(a[i] ^ b[i]); } ret } fn join(msg1_bytes: &[u8], msg2_bytes: &[u8]) { let decrypted_bytes = xor(msg1_bytes, msg2_bytes); let s = str::from_utf8(decrypted_bytes); println(s); }
xor
identifier_name
joiner.rs
use std::os; use std::io::File; use std::str; fn main() { let args: ~[~str] = os::args(); if args.len()!= 3
else { let tempArg = &args; let fname1 = &tempArg[1]; let fname2 = &tempArg[2]; let path1 = Path::new(fname1.clone()); let path2 = Path::new(fname2.clone()); let msg_file1 = File::open(&path1); let msg_file2 = File::open(&path2); match (msg_file1, msg_file2) { (Some(mut msg1), Some(mut msg2)) ...
{ println!("Usage: {:s} <inputfile>", args[0]); }
conditional_block
cgol.rs
use std::os; use std::rand; use std::rand::Rng; use std::io::Timer; use std::time::Duration; use std::clone::Clone; #[deriving(Clone)] struct Field { x: uint, y: uint, active: bool } fn next_round(field: &mut Vec<Vec<Field>>)
fn next_vitality(old_field: &Vec<Vec<Field>>, x: uint, y: uint) -> bool { let height = old_field.len(); let width = old_field[0].len(); let mut allowed_x: Vec<uint> = vec![x]; let mut allowed_y: Vec<uint> = vec![y]; if x > 0 { allowed_x.push(x-1); } if x < width-1 { allowed...
{ let old_field = field.clone(); for row in field.iter_mut() { for c in row.iter_mut() { c.active = next_vitality(&old_field, c.x, c.y); } } }
identifier_body
cgol.rs
use std::os; use std::rand; use std::rand::Rng; use std::io::Timer; use std::time::Duration; use std::clone::Clone; #[deriving(Clone)] struct Field { x: uint, y: uint, active: bool } fn next_round(field: &mut Vec<Vec<Field>>) { let old_field = field.clone(); for row in field.iter_mut() { ...
let mut total: int = 0; for i in allowed_x.iter() { for j in allowed_y.iter() { if *i == x && *j == y { continue; } if old_field[*j][*i].active == true { total += 1; } } } match total { 2 => old_fi...
{ allowed_y.push(y+1); }
conditional_block
cgol.rs
use std::os; use std::rand;
#[deriving(Clone)] struct Field { x: uint, y: uint, active: bool } fn next_round(field: &mut Vec<Vec<Field>>) { let old_field = field.clone(); for row in field.iter_mut() { for c in row.iter_mut() { c.active = next_vitality(&old_field, c.x, c.y); } } } fn next_vita...
use std::rand::Rng; use std::io::Timer; use std::time::Duration; use std::clone::Clone;
random_line_split
cgol.rs
use std::os; use std::rand; use std::rand::Rng; use std::io::Timer; use std::time::Duration; use std::clone::Clone; #[deriving(Clone)] struct
{ x: uint, y: uint, active: bool } fn next_round(field: &mut Vec<Vec<Field>>) { let old_field = field.clone(); for row in field.iter_mut() { for c in row.iter_mut() { c.active = next_vitality(&old_field, c.x, c.y); } } } fn next_vitality(old_field: &Vec<Vec<Field>>...
Field
identifier_name
default.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 ...
//! } //! //! #[derive(Default)] //! struct SomeOptions { //! foo: i32, //! bar: f32, //! baz: Kind, //! } //! //! //! fn main() { //! let options: SomeOptions = Default::default(); //! } //! ``` //! //! If you want to override a particular option, but still retain the other defaults: //! //! ``` //! # ...
random_line_split
class-poly-methods.rs
// run-pass #![allow(dead_code)] #![allow(non_camel_case_types)] struct cat<U> { info : Vec<U>, meows : usize, how_hungry : isize, } impl<U> cat<U> { pub fn speak<T>(&mut self, stuff: Vec<T> ) { self.meows += stuff.len(); } pub fn meow_count(&mut self) -> usize { self.meows } } fn c...
() { let mut nyan : cat<isize> = cat::<isize>(52, 99, vec![9]); let mut kitty = cat(1000, 2, vec!["tabby".to_string()]); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); nyan.speak(vec![1,2,3]); assert_eq!(nyan.meow_count(), 55); kitty.speak(vec!["meow".to_string(), "mew".to_string(), "pu...
main
identifier_name
class-poly-methods.rs
// run-pass #![allow(dead_code)] #![allow(non_camel_case_types)] struct cat<U> { info : Vec<U>, meows : usize, how_hungry : isize, } impl<U> cat<U> { pub fn speak<T>(&mut self, stuff: Vec<T> ) { self.meows += stuff.len(); } pub fn meow_count(&mut self) -> usize { self.meows } } fn c...
}
nyan.speak(vec![1,2,3]); assert_eq!(nyan.meow_count(), 55); kitty.speak(vec!["meow".to_string(), "mew".to_string(), "purr".to_string(), "chirp".to_string()]); assert_eq!(kitty.meow_count(), 1004);
random_line_split
class-poly-methods.rs
// run-pass #![allow(dead_code)] #![allow(non_camel_case_types)] struct cat<U> { info : Vec<U>, meows : usize, how_hungry : isize, } impl<U> cat<U> { pub fn speak<T>(&mut self, stuff: Vec<T> ) { self.meows += stuff.len(); } pub fn meow_count(&mut self) -> usize { self.meows } } fn c...
pub fn main() { let mut nyan : cat<isize> = cat::<isize>(52, 99, vec![9]); let mut kitty = cat(1000, 2, vec!["tabby".to_string()]); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); nyan.speak(vec![1,2,3]); assert_eq!(nyan.meow_count(), 55); kitty.speak(vec!["meow".to_string(), "mew".to_...
{ cat { meows: in_x, how_hungry: in_y, info: in_info } }
identifier_body
ltsv.rs
/*! Library for reading/writing Labeled Tab-Separated Values # Example ~~~~~~~~~~~~~~~~~~~~~~ extern mod ltsv; use ltsv::LTSVWriter; use ltsv::LTSVReader; fn main() { let infile = io::file_reader(&Path("path/fo/file.tlsv")).get(); for infile.read_ltsv().each |record| { for record.each |&(label, value...
*self.cur = self.rd.read_byte(); } } priv fn skip_whitespaces(&self) { while char::is_whitespace(*self.cur as char) { self.bump(); } } } #[cfg(test)] mod tests { use super::*; use core::io::WriterUtil; fn mk_record_string() -> ~str { do ...
} priv fn bump(&self) { if !self.eof() {
random_line_split
ltsv.rs
/*! Library for reading/writing Labeled Tab-Separated Values # Example ~~~~~~~~~~~~~~~~~~~~~~ extern mod ltsv; use ltsv::LTSVWriter; use ltsv::LTSVReader; fn main() { let infile = io::file_reader(&Path("path/fo/file.tlsv")).get(); for infile.read_ltsv().each |record| { for record.each |&(label, value...
(&self, f: &fn(&(~str, ~str)) -> bool) { let mut parser = LTSVParser::new(self); while!parser.eof() { match parser.parse_field() { ParseError(reason) => fail!(reason), ParseOk(_, _, field) => if!f(&field) { break; } } } } } struct LTSV...
each_ltsv_field
identifier_name
lib.rs
#![deny(missing_docs)] //! `hiirc` is a library built on top of [loirc](https://github.com/SBSTP/loirc). The goal //! is to offer a friendly, event-based API. //! //! To use the library, implement the `Listener` trait and give an instance of your implementation //! to the dispatch function, accompanied with an instance...
mod core; pub mod ext; mod listener; mod settings; pub use core::{dispatch}; pub use core::{Channel, ConnectionStatus, Error, Irc, IrcWrite, ChannelUser, ChannelUserStatus}; pub use listener::Listener; pub use settings::Settings; pub use loirc::Error as LoircError; pub use loirc::{Code, Event, Message, MonitorSettings...
extern crate encoding; extern crate loirc; #[macro_use] mod macros;
random_line_split
imports.rs
use std::path::PathBuf; use std::fs::File; use std::collections::HashMap; use errors::*; use ast::*; use symbols::*; use parser; use semantics; #[derive(Debug)] pub struct ModuleImporter { modules: HashMap<PathBuf, Module>, symbol_tables: HashMap<PathBuf, Scope>, search_paths: Vec<PathBuf>, } impl ModuleImport...
} module.imports.push(Import::new(String::from("Prelude"), Vec::new(), None)) } pub fn resolve_imports(&self, module: &mut Module) -> Result<Vec<PathBuf>> { try!(self.check_import_self(module)); self.inject_prelude(module); let mut file_paths = Vec::new(); for import in &module.imports ...
{ return (); }
conditional_block
imports.rs
use std::path::PathBuf; use std::fs::File; use std::collections::HashMap; use errors::*; use ast::*; use symbols::*; use parser; use semantics; #[derive(Debug)] pub struct ModuleImporter { modules: HashMap<PathBuf, Module>, symbol_tables: HashMap<PathBuf, Scope>, search_paths: Vec<PathBuf>, } impl ModuleImport...
(&mut self, file_path: PathBuf) -> Result<()> { if!self.symbol_tables.contains_key(&file_path) { // parse let source_file = try!(File::open(&file_path)); let mut ast = try!(parser::parse(&source_file)); // recursively import modules let mut root_scope: Scope = Default::default(); ...
import_module
identifier_name
imports.rs
use std::path::PathBuf; use std::fs::File; use std::collections::HashMap; use errors::*; use ast::*; use symbols::*; use parser; use semantics; #[derive(Debug)] pub struct ModuleImporter { modules: HashMap<PathBuf, Module>, symbol_tables: HashMap<PathBuf, Scope>, search_paths: Vec<PathBuf>, } impl ModuleImport...
fn check_import_self(&self, module: &mut Module) -> Result<()> { for import in &module.imports { if import.module_id == module.module_id { bail!(ErrorKind::ImportSelf(module.module_id.clone())); } } Ok(()) } fn inject_prelude(&self, module: &mut Module) { if module.module_i...
{ // generate file name from search path let mut module_path_buf = PathBuf::new(); for module_part in module_name.split('.') { module_path_buf.push(module_part); } module_path_buf.set_extension("silver"); // for all the search paths, check if the file exists for search_path in &self....
identifier_body
imports.rs
use std::path::PathBuf; use std::fs::File; use std::collections::HashMap; use errors::*; use ast::*; use symbols::*; use parser; use semantics; #[derive(Debug)] pub struct ModuleImporter { modules: HashMap<PathBuf, Module>, symbol_tables: HashMap<PathBuf, Scope>, search_paths: Vec<PathBuf>, } impl ModuleImport...
// inject into self self.modules.insert(file_path.clone(), ast); self.symbol_tables.insert(file_path.clone(), symbol_table); } Ok(()) } pub fn resolve_symbol_tables(&mut self, module: &mut Module) -> Result<Vec<&Scope>> { let resolved_module_paths = try!(self.resolve_imports(module...
let child_symbol_table = Scope::new(Some(Box::new(root_scope))); let symbol_table = try!(semantics::is_ast_valid(&ast, child_symbol_table));
random_line_split
errorevent.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::ErrorEventBinding; use dom::bindings::codegen::Bindings::ErrorEventBinding::...
// https://html.spec.whatwg.org/multipage/#dom-errorevent-colno fn Colno(self) -> u32 { self.colno.get() } // https://html.spec.whatwg.org/multipage/#dom-errorevent-message fn Message(self) -> DOMString { self.message.borrow().clone() } // https://html.spec.whatwg.org/mul...
{ self.lineno.get() }
identifier_body
errorevent.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::ErrorEventBinding; use dom::bindings::codegen::Bindings::ErrorEventBinding::...
(self) -> u32 { self.lineno.get() } // https://html.spec.whatwg.org/multipage/#dom-errorevent-colno fn Colno(self) -> u32 { self.colno.get() } // https://html.spec.whatwg.org/multipage/#dom-errorevent-message fn Message(self) -> DOMString { self.message.borrow().clone()...
Lineno
identifier_name
errorevent.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::ErrorEventBinding; use dom::bindings::codegen::Bindings::ErrorEventBinding::...
use std::cell::Cell; #[dom_struct] #[derive(HeapSizeOf)] pub struct ErrorEvent { event: Event, message: DOMRefCell<DOMString>, filename: DOMRefCell<DOMString>, lineno: Cell<u32>, colno: Cell<u32>, #[ignore_heap_size_of = "Defined in rust-mozjs"] error: MutHeapJSVal, } impl ErrorEventDerive...
use std::borrow::ToOwned;
random_line_split
lib.rs
extern crate chrono; extern crate copy_dir; #[macro_use] extern crate error_chain; #[macro_use] extern crate log; extern crate regex; #[macro_use] extern crate serde_derive; extern crate shlex; extern crate tempdir; #[cfg(test)] extern crate toml; pub mod errors; mod config; #[macro_use] pub mod helpers; use std::pa...
(root: &Path) -> Result<()> { cmd!(in root, "./x.py doc -v")?; Ok(()) } fn upload_docs(root: &Path, git_repo: &str) -> Result<()> { // FIXME: should probably not hard-code this... let target = "x86_64-unknown-linux-gnu"; let docs_dir = root.join("build").join(target).join("crate-docs"); if!do...
generate_docs
identifier_name