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
rc.rs
// "Tifflin" Kernel // - By John Hodge (thePowersGang)
use super::grc::Grc; /// Non-atomic reference counted type pub struct Rc<T:?Sized> { _inner: Grc<::core::cell::Cell<usize>, T>, } // Rc is not Send or Sync impl<T:?Sized>!Send for Rc<T> {} impl<T:?Sized>!Sync for Rc<T> {} impl<T:?Sized, U:?Sized> ops::CoerceUnsized<Rc<U>> for Rc<T> where T: ::core::marker::Unsize<U...
// // Core/lib/mem/rc.rs //! Reference-counted shared allocation use core::{ops,fmt};
random_line_split
rc.rs
// "Tifflin" Kernel // - By John Hodge (thePowersGang) // // Core/lib/mem/rc.rs //! Reference-counted shared allocation use core::{ops,fmt}; use super::grc::Grc; /// Non-atomic reference counted type pub struct Rc<T:?Sized> { _inner: Grc<::core::cell::Cell<usize>, T>, } // Rc is not Send or Sync impl<T:?Sized>!Send...
(&self, other: &Rc<T>) -> bool { self._inner.is_same( &other._inner ) } } impl<T:?Sized> Clone for Rc<T> { fn clone(&self) -> Rc<T> { Rc { _inner: self._inner.clone() } } } impl<T:?Sized + fmt::Display> fmt::Display for Rc<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { <T as fmt::Display>::fmt(...
is_same
identifier_name
interconnect.rs
use cpu::cpu::CPU; use cpu::mem::MMU; use cpu::gpu::GPU; pub struct Interconnect { pub mmu: MMU, pub gpu: GPU, } impl Interconnect { pub fn new() -> Self { Interconnect { mmu: MMU::new(), gpu: GPU::new(), } } pub fn read_word(&mut self) -> u16 { ...
(&mut self, value: u8, location: u16) { match location { 0x0000... 0x00FF => { println!("Restart and Interrupt Vectors"); }, 0x0100... 0x014F => { println!("Cartridge Header Area") }, 0x0150... 0x3FFF => { println!("Cartridge ROM - Bank 0 (fixed...
write_word
identifier_name
interconnect.rs
use cpu::cpu::CPU; use cpu::mem::MMU; use cpu::gpu::GPU; pub struct Interconnect { pub mmu: MMU, pub gpu: GPU, } impl Interconnect { pub fn new() -> Self { Interconnect { mmu: MMU::new(), gpu: GPU::new(), } } pub fn read_word(&mut self) -> u16 { ...
0x0000... 0x00FF => { println!("Restart and Interrupt Vectors"); }, 0x0100... 0x014F => { println!("Cartridge Header Area") }, 0x0150... 0x3FFF => { println!("Cartridge ROM - Bank 0 (fixed)") }, 0x4000... 0x7FFF => { println!("Cartridge ROM ...
match location {
random_line_split
interconnect.rs
use cpu::cpu::CPU; use cpu::mem::MMU; use cpu::gpu::GPU; pub struct Interconnect { pub mmu: MMU, pub gpu: GPU, } impl Interconnect { pub fn new() -> Self { Interconnect { mmu: MMU::new(), gpu: GPU::new(), } } pub fn read_word(&mut self) -> u16 { ...
}
{ println!("I'm a carrot!"); }
identifier_body
lib.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...
match self.inner { Mode::Tokio(ref remote) => remote.spawn(move |handle| { let future = f().into_future(); let timeout = Timeout::new(duration, handle).expect("Event loop is still up."); future.select(timeout.then(move |_| { on_timeout(); Ok(()) })).then(|_| Ok(())) }), Mode::Sync =...
{
random_line_split
lib.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 { let (stop, stopped) = futures::oneshot(); let (tx, rx) = mpsc::channel(); let handle = thread::spawn(move || { let mut el = tokio_core::reactor::Core::new().expect("Creating an event loop should not fail."); tx.send(el.remote()).expect("Rx is blocking upper thread."); let _ = el.run(futures:...
spawn
identifier_name
lib.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...
/// Synchronous remote, used mostly for tests. pub fn new_sync() -> Self { Remote { inner: Mode::Sync, } } /// Spawns a new thread for each future (use only for tests). pub fn new_thread_per_future() -> Self { Remote { inner: Mode::ThreadPerFuture, } } /// Spawn a future to this event loop pu...
{ Remote { inner: Mode::Tokio(remote), } }
identifier_body
mysql.rs
//! MySQL Driver implementation use std::path::PathBuf; use mysql::conn::{MyOpts, pool}; use configreader::ConfigReader; #[derive(Clone)] pub struct
{ pub pool: pool::MyPool, } fn get_opts(config: &mut ConfigReader) -> MyOpts { MyOpts { user: Some(config.get_value_or::<String>("MySQL.username", "root".to_string())), pass: Some(config.get_value_or::<String>("MySQL.password", "DidRPwfMySQL".to_string())), db_name: Some("reservat...
MySQL
identifier_name
mysql.rs
//! MySQL Driver implementation use std::path::PathBuf; use mysql::conn::{MyOpts, pool}; use configreader::ConfigReader; #[derive(Clone)] pub struct MySQL { pub pool: pool::MyPool, } fn get_opts(config: &mut ConfigReader) -> MyOpts { MyOpts { user: Some(config.get_value_or::<String>("MySQL.user...
}
{ let opts = get_opts(config); MySQL { pool: pool::MyPool::new(opts).unwrap(), } }
identifier_body
mysql.rs
//! MySQL Driver implementation use std::path::PathBuf; use mysql::conn::{MyOpts, pool}; use configreader::ConfigReader; #[derive(Clone)] pub struct MySQL { pub pool: pool::MyPool,
} fn get_opts(config: &mut ConfigReader) -> MyOpts { MyOpts { user: Some(config.get_value_or::<String>("MySQL.username", "root".to_string())), pass: Some(config.get_value_or::<String>("MySQL.password", "DidRPwfMySQL".to_string())), db_name: Some("reservator".to_string()), tcp_a...
random_line_split
main.rs
/** * Copyright (c) 2016 Alex Crichton * * Permission is hereby granted, free of charge, to any * person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the * Software without restriction, including without * limitation the rights to use, copy, modify, merge, ...
else { keys.push(MsgHdr::addr2str(&laddr)); if!keyaddr.is_empty() { keys.push(keyaddr.clone()); } } let (sink, stream) = Bytes.framed(stream).split(); let stdin_rx = stdin_rx.and_then(mov...
{ keys.push(keyval.clone()); }
conditional_block
main.rs
/** * Copyright (c) 2016 Alex Crichton * * Permission is hereby granted, free of charge, to any * person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the * Software without restriction, including without * limitation the rights to use, copy, modify, merge, ...
} impl Encoder for Bytes { type Item = Vec<u8>; type Error = io::Error; fn encode(&mut self, data: Vec<u8>, buf: &mut BytesMut) -> io::Result<()> { codecs::msg_encode(data, buf) } } fn read_stdin(mut rx: mpsc::Sender<Vec<u8>>) { let mut stdin = io::stdin(); let mut stdout = io::stdou...
{ self.decode(buf) }
identifier_body
main.rs
/** * Copyright (c) 2016 Alex Crichton * * Permission is hereby granted, free of charge, to any * person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the * Software without restriction, including without * limitation the rights to use, copy, modify, merge, ...
(&mut self, buf: &mut BytesMut) -> io::Result<Option<BytesMut>> { codecs::msg_decode(buf) } fn decode_eof(&mut self, buf: &mut BytesMut) -> io::Result<Option<BytesMut>> { self.decode(buf) } } impl Encoder for Bytes { type Item = Vec<u8>; type Error = io::Error; fn encode(&mut ...
decode
identifier_name
main.rs
/** * Copyright (c) 2016 Alex Crichton * * Permission is hereby granted, free of charge, to any * person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the * Software without restriction, including without * limitation the rights to use, copy, modify, merge, ...
} let (sink, stream) = Bytes.framed(stream).split(); let stdin_rx = stdin_rx.and_then(move |buf| { if None == key { //create hash for verification let decoded_message = Msg::decode(buf.as_slice()); ...
random_line_split
borrow.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 ...
(&self) -> &T { &**self } } #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T:?Sized> BorrowMut<T> for &'a mut T { fn borrow_mut(&mut self) -> &mut T { &mut **self } } impl<T> Borrow<T> for rc::Rc<T> { fn borrow(&self) -> &T { &**self } } impl<T> Borrow<T> for arc::Arc<T> { fn borrow(&self) -> &T ...
borrow
identifier_name
borrow.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 ...
} impl<T> Borrow<T> for arc::Arc<T> { fn borrow(&self) -> &T { &**self } } #[stable(feature = "rust1", since = "1.0.0")] impl<'a, B:?Sized> Borrow<B> for Cow<'a, B> where B: ToOwned, <B as ToOwned>::Owned: 'a { fn borrow(&self) -> &B { &**self } } /// A generalization of Clone to borrowed data. ...
{ &**self }
identifier_body
borrow.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 ...
impl<'a, T:?Sized> BorrowMut<T> for &'a mut T { fn borrow_mut(&mut self) -> &mut T { &mut **self } } impl<T> Borrow<T> for rc::Rc<T> { fn borrow(&self) -> &T { &**self } } impl<T> Borrow<T> for arc::Arc<T> { fn borrow(&self) -> &T { &**self } } #[stable(feature = "rust1", since = "1.0.0")] impl<'a, B:?Si...
#[stable(feature = "rust1", since = "1.0.0")]
random_line_split
issue-888-enum-var-decl-jump.rs
/* automatically generated by rust-bindgen */ #![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] use self::super::root; pub mod Halide { ...
} #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum a { __bindgen_cannot_repr_c_on_empty_enum = 0, } }
{ assert_eq!( ::std::mem::size_of::<Type>(), 1usize, concat!("Size of: ", stringify!(Type)) ); assert_eq!( ::std::mem::align_of::<Type>(), 1usize, concat!("Alignment of ", stringify!(Type)...
identifier_body
issue-888-enum-var-decl-jump.rs
/* automatically generated by rust-bindgen */ #![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] use self::super::root; pub mod Halide { ...
{ __bindgen_cannot_repr_c_on_empty_enum = 0, } }
a
identifier_name
issue-888-enum-var-decl-jump.rs
/* automatically generated by rust-bindgen */ #![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] use self::super::root; pub mod Halide { ...
assert_eq!( ::std::mem::align_of::<Type>(), 1usize, concat!("Alignment of ", stringify!(Type)) ); } } #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum a { __bindgen_cannot_repr_c_on_empty_enum...
::std::mem::size_of::<Type>(), 1usize, concat!("Size of: ", stringify!(Type)) );
random_line_split
summary.rs
//! Summary subset of a Manifest use std::collections::HashMap; use std::mem; use dependency::Dependency; use package_id::PackageId; use semver::Version; use source::SourceId; use util::CraftResult; /// Subset of a `Manifest`. Contains only the most important informations about a package. /// Summaries are cloned, an...
pub fn version(&self) -> &Version { self.package_id().version() } pub fn source_id(&self) -> &SourceId { self.package_id.source_id() } pub fn dependencies(&self) -> &[Dependency] { &self.dependencies } pub fn features(&self) -> &HashMap<String, Vec<String>> { ...
{ self.package_id().name() }
identifier_body
summary.rs
//! Summary subset of a Manifest use std::collections::HashMap; use std::mem; use dependency::Dependency; use package_id::PackageId; use semver::Version; use source::SourceId; use util::CraftResult; /// Subset of a `Manifest`. Contains only the most important informations about a package. /// Summaries are cloned, an...
(pkg_id: PackageId, dependencies: Vec<Dependency>, features: HashMap<String, Vec<String>>) -> CraftResult<Summary> { for dep in dependencies.iter() { if features.get(dep.name()).is_some() { bail!("Features and dependencies cannot have the ...
new
identifier_name
summary.rs
//! Summary subset of a Manifest use std::collections::HashMap; use std::mem; use dependency::Dependency; use package_id::PackageId; use semver::Version; use source::SourceId; use util::CraftResult; /// Subset of a `Manifest`. Contains only the most important informations about a package. /// Summaries are cloned, an...
self } pub fn map_source(self, to_replace: &SourceId, replace_with: &SourceId) -> Summary { let me = if self.package_id().source_id() == to_replace { let new_id = self.package_id().with_source_id(replace_with); self.override_id(new_id) } else { self ...
let deps = mem::replace(&mut self.dependencies, Vec::new()); self.dependencies = deps.into_iter().map(f).collect();
random_line_split
summary.rs
//! Summary subset of a Manifest use std::collections::HashMap; use std::mem; use dependency::Dependency; use package_id::PackageId; use semver::Version; use source::SourceId; use util::CraftResult; /// Subset of a `Manifest`. Contains only the most important informations about a package. /// Summaries are cloned, an...
if dep.is_optional() &&!dep.is_transitive() { bail!("Dev-dependencies are not allowed to be optional: `{}`", dep.name()) } } for (feature, list) in features.iter() { for dep in list.iter() { let mut parts = dep.sp...
{ bail!("Features and dependencies cannot have the same name: `{}`", dep.name()) }
conditional_block
borrowck-closures-use-after-free.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 ...
}
random_line_split
borrowck-closures-use-after-free.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let mut ptr = box Foo { x: 0 }; let mut test = |foo: &Foo| { ptr = box Foo { x: ptr.x + 1 }; }; test(&*ptr); //~ ERROR cannot borrow `*ptr` }
main
identifier_name
borrowck-closures-use-after-free.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 ...
} fn main() { let mut ptr = box Foo { x: 0 }; let mut test = |foo: &Foo| { ptr = box Foo { x: ptr.x + 1 }; }; test(&*ptr); //~ ERROR cannot borrow `*ptr` }
{ println!("drop {}", self.x); }
identifier_body
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // For simd (currently x86_64/aarch64) #![cfg_attr(any(target_arch = "x86_64", target_arch = "aarch64"), feature(c...
pub mod platform; // Text #[path = "text/mod.rs"] pub mod text;
random_line_split
test_pinky.rs
extern crate uucore; use common::util::*; use self::uucore::entries::{Locate, Passwd}; extern crate uu_pinky; pub use self::uu_pinky::*; #[test] fn test_capitalize() { assert_eq!("Zbnmasd", "zbnmasd".capitalize()); assert_eq!("Abnmasd", "Abnmasd".capitalize()); assert_eq!("1masd", "1masd".capitalize());...
#[cfg(target_os = "linux")] fn expected_result(args: &[&str]) -> String { TestScenario::new(util_name!()).cmd_keepenv(util_name!()).env("LANGUAGE", "C").args(args).run().stdout }
{ let scene = TestScenario::new(util_name!()); let args = ["-i"]; scene.ucmd().args(&args).run().stdout_is(expected_result(&args)); let args = ["-q"]; scene.ucmd().args(&args).run().stdout_is(expected_result(&args)); }
identifier_body
test_pinky.rs
extern crate uucore; use common::util::*; use self::uucore::entries::{Locate, Passwd}; extern crate uu_pinky; pub use self::uu_pinky::*; #[test] fn test_capitalize() { assert_eq!("Zbnmasd", "zbnmasd".capitalize()); assert_eq!("Abnmasd", "Abnmasd".capitalize()); assert_eq!("1masd", "1masd".capitalize());...
TestScenario::new(util_name!()).cmd_keepenv(util_name!()).env("LANGUAGE", "C").args(args).run().stdout }
random_line_split
test_pinky.rs
extern crate uucore; use common::util::*; use self::uucore::entries::{Locate, Passwd}; extern crate uu_pinky; pub use self::uu_pinky::*; #[test] fn
() { assert_eq!("Zbnmasd", "zbnmasd".capitalize()); assert_eq!("Abnmasd", "Abnmasd".capitalize()); assert_eq!("1masd", "1masd".capitalize()); assert_eq!("", "".capitalize()); } #[test] fn test_long_format() { let ulogin = "root"; let pw: Passwd = Passwd::locate(ulogin).unwrap(); let real_na...
test_capitalize
identifier_name
morestack4.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 ...
struct and_then_get_big_again { x:int, } impl Drop for and_then_get_big_again { fn drop(&mut self) {} } fn and_then_get_big_again(x:int) -> and_then_get_big_again { and_then_get_big_again { x: x } } fn main() { do task::spawn { getbig_and_fail(1); }; }
{ let r = and_then_get_big_again(5); if i != 0 { getbig_and_fail(i - 1); } else { fail!(); } }
identifier_body
morestack4.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 ...
(x:int) -> and_then_get_big_again { and_then_get_big_again { x: x } } fn main() { do task::spawn { getbig_and_fail(1); }; }
and_then_get_big_again
identifier_name
morestack4.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 ...
} struct and_then_get_big_again { x:int, } impl Drop for and_then_get_big_again { fn drop(&mut self) {} } fn and_then_get_big_again(x:int) -> and_then_get_big_again { and_then_get_big_again { x: x } } fn main() { do task::spawn { getbig_and_fail(1); }; }
{ fail!(); }
conditional_block
morestack4.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn and_then_get_big_again(x:int) -> and_then_get_big_again { and_then_get_big_again { x: x } } fn main() { do task::spawn { getbig_and_fail(1); }; }
impl Drop for and_then_get_big_again { fn drop(&mut self) {}
random_line_split
simple.rs
/* * Copyright (c) 2017-2020 Boucher, Antoni <bouanto@zoho.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, ...
(&mut self) { self.widgets.label.set_text("Test"); } fn model() -> LabelModel { LabelModel { counter: 0, } } fn update(&mut self, _event: LabelMsg) { self.widgets.label.set_text(""); } view! { #[name="label"] gtk::Label { ...
init_view
identifier_name
simple.rs
/* * Copyright (c) 2017-2020 Boucher, Antoni <bouanto@zoho.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, ...
#[cfg(test)] mod tests { use gtk::prelude::LabelExt; use gtk_test::assert_text; use crate::Win; #[test] fn root_widget() { let (_component, _, widgets) = relm::init_test::<Win>(()).expect("init_test failed"); let label = &widgets.label; assert_text!(label, "Test"); }...
{ Win::run(()).expect("Win::run failed"); }
identifier_body
simple.rs
/* * Copyright (c) 2017-2020 Boucher, Antoni <bouanto@zoho.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, ...
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */...
random_line_split
iter_count.rs
use super::utils::derefs_to_slice; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_span::sym; use super::ITER_COUNT; pub(...
<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, recv: &'tcx Expr<'tcx>, iter_method: &str) { let ty = cx.typeck_results().expr_ty(recv); let caller_type = if derefs_to_slice(cx, recv, ty).is_some() { "slice" } else if is_type_diagnostic_item(cx, ty, sym::vec_type) { "Vec" } else if is_ty...
check
identifier_name
iter_count.rs
use super::utils::derefs_to_slice; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; use rustc_hir::Expr;
pub(crate) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, recv: &'tcx Expr<'tcx>, iter_method: &str) { let ty = cx.typeck_results().expr_ty(recv); let caller_type = if derefs_to_slice(cx, recv, ty).is_some() { "slice" } else if is_type_diagnostic_item(cx, ty, sym::vec_type) { "Vec"...
use rustc_lint::LateContext; use rustc_span::sym; use super::ITER_COUNT;
random_line_split
iter_count.rs
use super::utils::derefs_to_slice; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_span::sym; use super::ITER_COUNT; pub(...
else if is_type_diagnostic_item(cx, ty, sym::BinaryHeap) { "BinaryHeap" } else { return; }; let mut applicability = Applicability::MachineApplicable; span_lint_and_sugg( cx, ITER_COUNT, expr.span, &format!("called `.{}().count()` on a `{}`", iter_method, ...
{ "LinkedList" }
conditional_block
iter_count.rs
use super::utils::derefs_to_slice; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_span::sym; use super::ITER_COUNT; pub(...
} else { return; }; let mut applicability = Applicability::MachineApplicable; span_lint_and_sugg( cx, ITER_COUNT, expr.span, &format!("called `.{}().count()` on a `{}`", iter_method, caller_type), "try", format!( "{}.len()", ...
{ let ty = cx.typeck_results().expr_ty(recv); let caller_type = if derefs_to_slice(cx, recv, ty).is_some() { "slice" } else if is_type_diagnostic_item(cx, ty, sym::vec_type) { "Vec" } else if is_type_diagnostic_item(cx, ty, sym::vecdeque_type) { "VecDeque" } else if is_type_d...
identifier_body
frwz_nk.rs
%------------------------------------------------------------- % Nonlinear New Keynesian Model % Reference: Foerster, Rubio-Ramirez, Waggoner and Zha (2013) % Perturbation Methods for Markov Switching Models. %------------------------------------------------------------- endogenous PAI, "Inflation", Y, "Output gap", R...
steady_state_model PAI=1; Y=(eta-1)/eta; R=exp(mu)/betta*PAI; parameterization a_tp_1_2,1-.9; a_tp_2_1,1-.9; betta,.99; kappa, 161; eta, 10; rhor,.8; sigr, 0.0025; mu(a,1), 0.03; mu(a,2), 0.01; psi(a,1), 3.1; psi(a,2), 0.9;
random_line_split
backend.rs
use std::env; use std::time::SystemTime; use rand; use rand::Rng; use dotenv::dotenv; use diesel; use diesel::prelude::*; use diesel::pg::PgConnection; use ::services::schema::{ users as us, quotes as qu, quotes::dsl::*, users::dsl::*, }; use super::models::*; pub struct Backend { connection: P...
pub fn random_quote(&self) -> QueryResult<(User, Quote)> { let mut rng = rand::thread_rng(); let offset = rng.gen_range(0, quotes.count().get_result(&self.connection)?); // Try to query for a quote using a random offset let qres: Quote = quotes.offset(offset).first(&self.connectio...
{ diesel::delete(quotes.filter(qu::dsl::id.eq(quote_id))) .get_result(&self.connection) }
identifier_body
backend.rs
use std::env; use std::time::SystemTime; use rand; use rand::Rng; use dotenv::dotenv; use diesel; use diesel::prelude::*; use diesel::pg::PgConnection;
quotes as qu, quotes::dsl::*, users::dsl::*, }; use super::models::*; pub struct Backend { connection: PgConnection } impl Backend { pub fn new() -> Self { dotenv().ok(); let database_url = env::var("DATABASE_URL") .expect("DATABASE_URL must be set"); let conne...
use ::services::schema::{ users as us,
random_line_split
backend.rs
use std::env; use std::time::SystemTime; use rand; use rand::Rng; use dotenv::dotenv; use diesel; use diesel::prelude::*; use diesel::pg::PgConnection; use ::services::schema::{ users as us, quotes as qu, quotes::dsl::*, users::dsl::*, }; use super::models::*; pub struct Backend { connection: P...
}; let new_quote = NewQuote { quoter_id: user.id, time: SystemTime::now(), value: quote, }; Ok(diesel::insert(&new_quote).into(qu::table) .get_result::<Quote>(&self.connection)?.id) } pub fn get_quote(&self, quote_id: i32) -> Qu...
{ let new_user = NewUser { user_id: user }; diesel::insert(&new_user).into(us::table) .get_result(&self.connection)? }
conditional_block
backend.rs
use std::env; use std::time::SystemTime; use rand; use rand::Rng; use dotenv::dotenv; use diesel; use diesel::prelude::*; use diesel::pg::PgConnection; use ::services::schema::{ users as us, quotes as qu, quotes::dsl::*, users::dsl::*, }; use super::models::*; pub struct
{ connection: PgConnection } impl Backend { pub fn new() -> Self { dotenv().ok(); let database_url = env::var("DATABASE_URL") .expect("DATABASE_URL must be set"); let connection = PgConnection::establish(&database_url) .expect(&format!("Error connecting to {}", d...
Backend
identifier_name
builtin-superkinds-in-metadata.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT.
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // aux-build:trait...
//
random_line_split
builtin-superkinds-in-metadata.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { }
main
identifier_name
poll.rs
/// A macro for extracting the successful type of a `Poll<T, E>`. /// /// This macro bakes propagation of both errors and `NotReady` signals by /// returning early. #[macro_export] macro_rules! try_ready { ($e:expr) => (match $e { Ok($crate::Async::Ready(t)) => t, Ok($crate::Async::NotReady) => retu...
/// Returns whether this is `Async::NotReady` pub fn is_not_ready(&self) -> bool { !self.is_ready() } } impl<T> From<T> for Async<T> { fn from(t: T) -> Async<T> { Async::Ready(t) } } /// The result of an asynchronous attempt to send a value to a sink. #[derive(Copy, Clone, Debug, ...
{ match *self { Async::Ready(_) => true, Async::NotReady => false, } }
identifier_body
poll.rs
/// A macro for extracting the successful type of a `Poll<T, E>`. /// /// This macro bakes propagation of both errors and `NotReady` signals by /// returning early. #[macro_export] macro_rules! try_ready { ($e:expr) => (match $e { Ok($crate::Async::Ready(t)) => t, Ok($crate::Async::NotReady) => retu...
/// Returns whether this is `AsyncSink::NotReady` pub fn is_not_ready(&self) -> bool { !self.is_ready() } } /// Return type of the `Sink::start_send` method, indicating the outcome of a /// send attempt. See `AsyncSink` for more details. pub type StartSend<T, E> = Result<AsyncSink<T>, E>;
AsyncSink::Ready => true, AsyncSink::NotReady(_) => false, } }
random_line_split
poll.rs
/// A macro for extracting the successful type of a `Poll<T, E>`. /// /// This macro bakes propagation of both errors and `NotReady` signals by /// returning early. #[macro_export] macro_rules! try_ready { ($e:expr) => (match $e { Ok($crate::Async::Ready(t)) => t, Ok($crate::Async::NotReady) => retu...
<T> { /// The `start_send` attempt succeeded, so the sending process has /// *started*; you muse use `Sink::poll_complete` to drive the send /// to completion. Ready, /// The `start_send` attempt failed due to the sink being full. The value /// being sent is returned, and the current `Task` wil...
AsyncSink
identifier_name
option.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 base::prelude::*; use {Write, LowerHex, UpperHex, Debug, Display}; macro_rules! imp { ($ty:ident) => { ...
} imp!(LowerHex); imp!(UpperHex); imp!(Debug); imp!(Display);
} } }
random_line_split
core.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 command_line::command_line_init; use interfaces::cef_app_t; use types::{cef_main_args_t, cef_settings_t}; use...
}; let mut temp_opts = opts::default_opts(); temp_opts.urls = vec![HOME_URL.to_owned()]; temp_opts.paint_threads = rendering_threads; temp_opts.layout_threads = rendering_threads; temp_opts.headless = false; temp_opts.hard_fail = false; temp_opts.enable_text_antialiasing = true; te...
{ (*settings).rendering_threads as uint }
conditional_block
core.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 command_line::command_line_init; use interfaces::cef_app_t; use types::{cef_main_args_t, cef_settings_t}; use...
(args: *const cef_main_args_t, settings: *mut cef_settings_t, application: *mut cef_app_t, _windows_sandbox_info: *const c_void) -> c_int { if args.is_null() { return 0; } ...
cef_initialize
identifier_name
core.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 command_line::command_line_init; use interfaces::cef_app_t; use types::{cef_main_args_t, cef_settings_t}; use...
_app: *mut cef_app_t, _windows_sandbox_info: *mut c_void) -> c_int { -1 } #[no_mangle] pub extern "C" fn cef_api_hash(entry: c_int) -> *const c_char { if entry == 0 { &CEF_API_HASH_PLATFORM[...
pub extern "C" fn cef_quit_message_loop() { } #[no_mangle] pub extern "C" fn cef_execute_process(_args: *const cef_main_args_t,
random_line_split
core.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 command_line::command_line_init; use interfaces::cef_app_t; use types::{cef_main_args_t, cef_settings_t}; use...
#[no_mangle] pub extern "C" fn cef_log(_file: *const c_char, _line: c_int, _severity: c_int, message: *const c_char) { unsafe { let slice = ffi::c_str_to_bytes(&message); println!("{}", str::from_utf8(slice).unwrap()) ...
{ if entry == 0 { &CEF_API_HASH_PLATFORM[0] as *const u8 as *const c_char } else { &CEF_API_HASH_UNIVERSAL[0] as *const u8 as *const c_char } }
identifier_body
restyle_damage.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/. */ //! The restyle damage is a hint that tells layout which kind of operations may //! be needed in presence of incre...
get_inheritedtable.empty_cells, get_inheritedtable.caption_side, get_column.column_width, get_column.column_count ]) || (new.get_box().display == display::T::inline && add_if_not_equal!(old, new, damage, [REPAINT, REPOSITION, STORE_OVERFLOW, BUBBLE_ISIZES, ...
get_font.font_size, get_font.font_stretch, get_inheritedbox.direction, get_inheritedbox.writing_mode, get_text.text_decoration_line, get_text.unicode_bidi,
random_line_split
restyle_damage.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/. */ //! The restyle damage is a hint that tells layout which kind of operations may //! be needed in presence of incre...
/// Returns a bitmask that represents a flow that needs to be rebuilt and /// reflowed. /// /// FIXME(bholley): Do we ever actually need this? Shouldn't /// RECONSTRUCT_FLOW imply everything else? pub fn rebuild_and_reflow() -> ServoRestyleDamage { REPAINT | REPOSITION | STORE_OVERFLOW...
{ let damage = compute_damage(old, new); let change = if damage.is_empty() { StyleChange::Unchanged } else { // FIXME(emilio): Differentiate between reset and inherited // properties here, and set `reset_only` appropriately so the // optimization t...
identifier_body
restyle_damage.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/. */ //! The restyle damage is a hint that tells layout which kind of operations may //! be needed in presence of incre...
( old: &ComputedValues, new: &ComputedValues, ) -> StyleDifference { let damage = compute_damage(old, new); let change = if damage.is_empty() { StyleChange::Unchanged } else { // FIXME(emilio): Differentiate between reset and inherited // p...
compute_style_difference
identifier_name
lib.rs
// Copyright 2015 Hyunsik Choi // // 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 agre...
/// Rust APIs wrapping libhdfs API, providing better semantic and abstraction pub mod dfs; /// Mini HDFS Cluster for easily building unit tests pub mod minidfs; pub mod util;
random_line_split
extern-pass-TwoU16s.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 ...
// xfail-test #5744 #[deriving(Eq)] struct TwoU16s { one: u16, two: u16 } pub extern { pub fn rust_dbg_extern_identity_TwoU16s(v: TwoU16s) -> TwoU16s; } pub fn main() { unsafe { let x = TwoU16s {one: 22, two: 23}; let y = rust_dbg_extern_identity_TwoU16s(x); assert_eq!(x, y); ...
random_line_split
extern-pass-TwoU16s.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 = TwoU16s {one: 22, two: 23}; let y = rust_dbg_extern_identity_TwoU16s(x); assert_eq!(x, y); } }
identifier_body
extern-pass-TwoU16s.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 = TwoU16s {one: 22, two: 23}; let y = rust_dbg_extern_identity_TwoU16s(x); assert_eq!(x, y); } }
main
identifier_name
to_string.rs
use std::fmt::{Display, Formatter, Result, Write}; use Rational; impl Display for Rational { /// Converts a `Rational` to a `String`. /// /// # Worst-case complexity /// TODO /// /// # Examples /// ``` /// extern crate malachite_base; /// /// use malachite_base::num::basic::trai...
else { result } } }
{ f.write_char('/')?; Display::fmt(&self.denominator, f) }
conditional_block
to_string.rs
use std::fmt::{Display, Formatter, Result, Write}; use Rational; impl Display for Rational { /// Converts a `Rational` to a `String`. /// /// # Worst-case complexity /// TODO /// /// # Examples /// ``` /// extern crate malachite_base; /// /// use malachite_base::num::basic::trai...
/// ``` fn fmt(&self, f: &mut Formatter) -> Result { if!self.sign { f.write_char('-')?; } let result = Display::fmt(&self.numerator, f); if self.denominator!= 1 { f.write_char('/')?; Display::fmt(&self.denominator, f) } else { ...
/// use std::str::FromStr; /// /// assert_eq!(Rational::ZERO.to_string(), "0"); /// assert_eq!(Rational::from(123).to_string(), "123"); /// assert_eq!(Rational::from_str("22/7").unwrap().to_string(), "22/7");
random_line_split
to_string.rs
use std::fmt::{Display, Formatter, Result, Write}; use Rational; impl Display for Rational { /// Converts a `Rational` to a `String`. /// /// # Worst-case complexity /// TODO /// /// # Examples /// ``` /// extern crate malachite_base; /// /// use malachite_base::num::basic::trai...
}
{ if !self.sign { f.write_char('-')?; } let result = Display::fmt(&self.numerator, f); if self.denominator != 1 { f.write_char('/')?; Display::fmt(&self.denominator, f) } else { result } }
identifier_body
to_string.rs
use std::fmt::{Display, Formatter, Result, Write}; use Rational; impl Display for Rational { /// Converts a `Rational` to a `String`. /// /// # Worst-case complexity /// TODO /// /// # Examples /// ``` /// extern crate malachite_base; /// /// use malachite_base::num::basic::trai...
(&self, f: &mut Formatter) -> Result { if!self.sign { f.write_char('-')?; } let result = Display::fmt(&self.numerator, f); if self.denominator!= 1 { f.write_char('/')?; Display::fmt(&self.denominator, f) } else { result } ...
fmt
identifier_name
xcb.rs
use libc::{c_int, c_char, c_uchar, c_ushort, c_uint}; use std::ptr; use std::mem; use std::default::Default; // CONSTANTS const XCB_WINDOW_CLASS_INPUT_OUTPUT: c_ushort = 1; const XCB_GC_FOREGROUND: c_uint = 4; const XCB_GC_GRAPHICS_EXPOSURES: c_uint = 65536; const XCB_CW_BACK_PIXEL: c_uint = 2; const XCB_CW_EVENT_M...
}
{ match self.screen { None => unsafe { let iterator = xcb_setup_roots_iterator( xcb_get_setup(self.connection) ); self.screen = Some(iterator.data); }, Some(_) => () } }
identifier_body
xcb.rs
use libc::{c_int, c_char, c_uchar, c_ushort, c_uint}; use std::ptr; use std::mem; use std::default::Default; // CONSTANTS const XCB_WINDOW_CLASS_INPUT_OUTPUT: c_ushort = 1; const XCB_GC_FOREGROUND: c_uint = 4; const XCB_GC_GRAPHICS_EXPOSURES: c_uint = 65536; const XCB_CW_BACK_PIXEL: c_uint = 2; const XCB_CW_EVENT_M...
() -> XCBGenericEventFFI { unsafe { mem::zeroed() } } } #[repr(C)] #[derive(Copy)] pub struct XCBRectangleFFI { pub x: c_ushort, pub y: c_ushort, pub width: c_ushort, pub height: c_ushort, } impl Default for XCBRectangleFFI { fn default() -> XCBRectangleFFI { unsafe { mem::zeroed() } } } // FUNC...
default
identifier_name
xcb.rs
use libc::{c_int, c_char, c_uchar, c_ushort, c_uint}; use std::ptr; use std::mem; use std::default::Default; // CONSTANTS const XCB_WINDOW_CLASS_INPUT_OUTPUT: c_ushort = 1; const XCB_GC_FOREGROUND: c_uint = 4; const XCB_GC_GRAPHICS_EXPOSURES: c_uint = 65536; const XCB_CW_BACK_PIXEL: c_uint = 2; const XCB_CW_EVENT_M...
} } } fn init_screen(&mut self) { match self.screen { None => unsafe { let iterator = xcb_setup_roots_iterator( xcb_get_setup(self.connection) ); self.screen = Some(iterator.data); }, ...
{ // XCB_KEY_PRESS break; }
conditional_block
xcb.rs
use libc::{c_int, c_char, c_uchar, c_ushort, c_uint}; use std::ptr; use std::mem; use std::default::Default; // CONSTANTS const XCB_WINDOW_CLASS_INPUT_OUTPUT: c_ushort = 1; const XCB_GC_FOREGROUND: c_uint = 4; const XCB_GC_GRAPHICS_EXPOSURES: c_uint = 65536; const XCB_CW_BACK_PIXEL: c_uint = 2; const XCB_CW_EVENT_M...
unsafe { let screen = *self.screen.unwrap(); let windowp = self.window.unwrap(); let foreground = xcb_generate_id(self.connection); let mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES; let value_list: [u32; 2] = [screen.black_pixel, 0]; ...
} pub fn exec(&self) {
random_line_split
nb30.rs
// Copyright © 2015-2017 winapi-rs developers
// All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! This module contains the definitions for portable NetBIOS 3.0 support. use shared::minwindef::{DWORD, PUCHAR, UCHAR, ULONG, USHORT, WORD}; use um::winnt::HANDLE; pub const NCBNAMSZ: usize...
// 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.
random_line_split
types.rs
// Copyright 2015 Ted Mielczarek. See the COPYRIGHT // file at the top-level directory of this distribution. use range_map::{Range, RangeMap}; use std::cmp::Ordering; use std::collections::HashMap; /// A publicly visible linker symbol. #[derive(Debug, Eq, PartialEq)] pub struct PublicSymbol { /// The symbol's add...
self.address, self.address.checked_add(self.size as u64)? - 1, )) } } /// A parsed.sym file containing debug symbols. #[derive(Debug, PartialEq)] pub struct SymbolFile { /// The set of source files involved in compilation. pub files: HashMap<u32, String>, /// Publicly vi...
if self.size == 0 { return None; } Some(Range::new(
random_line_split
types.rs
// Copyright 2015 Ted Mielczarek. See the COPYRIGHT // file at the top-level directory of this distribution. use range_map::{Range, RangeMap}; use std::cmp::Ordering; use std::collections::HashMap; /// A publicly visible linker symbol. #[derive(Debug, Eq, PartialEq)] pub struct PublicSymbol { /// The symbol's add...
{ /// The initial rules for this address range. pub init: CfiRules, /// The size of this entire address range. pub size: u32, /// Additional rules to use at specified addresses. pub add_rules: Vec<CfiRules>, } impl StackInfoCfi { pub fn memory_range(&self) -> Option<Range<u64>> { i...
StackInfoCfi
identifier_name
types.rs
// Copyright 2015 Ted Mielczarek. See the COPYRIGHT // file at the top-level directory of this distribution. use range_map::{Range, RangeMap}; use std::cmp::Ordering; use std::collections::HashMap; /// A publicly visible linker symbol. #[derive(Debug, Eq, PartialEq)] pub struct PublicSymbol { /// The symbol's add...
Some(Range::new( self.address, self.address.checked_add(self.size as u64)? - 1, )) } } /// A parsed.sym file containing debug symbols. #[derive(Debug, PartialEq)] pub struct SymbolFile { /// The set of source files involved in compilation. pub files: HashMap<u32, St...
{ return None; }
conditional_block
util.rs
/* Copyright ⓒ 2016 Daniel Keep. Licensed under the MIT license (see LICENSE or <http://opensource.org /licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of <http://www.apache.org/licenses/LICENSE-2.0>), at your option. All files in the project carrying such notice may not be copied, modified, or distribu...
self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&self.0, fmt) } } impl Display for MsgErr { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { Display::fmt(&self.0, fmt) } } impl Error for MsgErr { fn description(&self) -> &str { self.0 } } /** Vario...
t(&
identifier_name
util.rs
/* Copyright ⓒ 2016 Daniel Keep. Licensed under the MIT license (see LICENSE or <http://opensource.org /licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of <http://www.apache.org/licenses/LICENSE-2.0>), at your option. All files in the project carrying such notice may not be copied, modified, or distribu...
LoneSlash, /// Backslash followed by unrecognised character. UnknownEscape(char), /// Malformed hex escape sequence. MalformedHex, /// Malformed unicode escape sequence. MalformedUnicode, /// Escape contained an invalid value. InvalidValue, } impl Display for EscapeError { fn fm...
/// Backslash with nothing after it.
random_line_split
dc.rs
/*! DC (Distance Coding) forward and backward transformation. Designed to be used on BWT block output for compression. # Links http://www.data-compression.info/Algorithms/DC/ # Example ```rust use compress::bwt::dc; let bytes = b"abracadabra"; let distances = dc::encode_simple::<usize>(bytes); let decoded = dc::d...
<F>(mut next: [usize; TOTAL_SYMBOLS], output: &mut [Symbol], mtf: &mut MTF, mut fn_dist: F) -> io::Result<()> where F: FnMut(Context) -> io::Result<usize> { let n = output.len(); let mut i = 0; for (sym,d) in next.iter().enumerate() { if *d < n { let mut j = i; ...
decode
identifier_name
dc.rs
/*! DC (Distance Coding) forward and backward transformation. Designed to be used on BWT block output for compression. # Links http://www.data-compression.info/Algorithms/DC/ # Example ```rust use compress::bwt::dc; let bytes = b"abracadabra"; let distances = dc::encode_simple::<usize>(bytes); let decoded = dc::d...
/// Encode a block of bytes 'input' /// write output distance stream into 'distances' /// return: unique bytes encountered in the order they appear /// with the corresponding initial distances pub fn encode<'a, 'b, D: Clone + Copy + Eq + NumCast>(input: &'a [Symbol], distances: &'b mut [D], mtf: &mut MTF) -> EncodeIte...
} }
random_line_split
dc.rs
/*! DC (Distance Coding) forward and backward transformation. Designed to be used on BWT block output for compression. # Links http://www.data-compression.info/Algorithms/DC/ # Example ```rust use compress::bwt::dc; let bytes = b"abracadabra"; let distances = dc::encode_simple::<usize>(bytes); let decoded = dc::d...
/// get the initial symbol positions, to be called before iteration pub fn get_init<'c>(&'c self) -> &'c [usize; TOTAL_SYMBOLS] { assert_eq!(self.last_active, 0); &self.pos } } impl<'a, 'b, D> Iterator for EncodeIterator<'a,'b,D> where D: Clone + Eq + NumCast + 'b { type Item = (D...
{ assert_eq!(input.len(), dist.len()); EncodeIterator { data: input.iter().zip(dist.iter()).enumerate(), pos: init, last_active: 0, size: input.len() } }
identifier_body
3_09_wave_b.rs
// The Nature of Code // Daniel Shiffman // http://natureofcode.com // // Example 3-9: Wave_B use nannou::prelude::*; fn main() { nannou::app(model).update(update).run(); } struct Model { start_angle: f32, angle_vel: f32, } fn model(app: &App) -> Model { app.new_window().size(250, 200).view(view).bui...
angle += model.angle_vel; x += 24.0; } // Write the result of our drawing to the window's frame. draw.to_frame(app, &frame).unwrap(); }
random_line_split
3_09_wave_b.rs
// The Nature of Code // Daniel Shiffman // http://natureofcode.com // // Example 3-9: Wave_B use nannou::prelude::*; fn main() { nannou::app(model).update(update).run(); } struct Model { start_angle: f32, angle_vel: f32, } fn model(app: &App) -> Model { app.new_window().size(250, 200).view(view).bui...
fn view(app: &App, model: &Model, frame: Frame) { // Begin drawing let draw = app.draw(); draw.background().color(WHITE); let mut angle = model.start_angle; let rect = app.window_rect(); let mut x = rect.left(); while x <= rect.right() { let y = map_range(angle.sin(), -1.0, 1.0, r...
{ model.start_angle += 0.015; }
identifier_body
3_09_wave_b.rs
// The Nature of Code // Daniel Shiffman // http://natureofcode.com // // Example 3-9: Wave_B use nannou::prelude::*; fn main() { nannou::app(model).update(update).run(); } struct
{ start_angle: f32, angle_vel: f32, } fn model(app: &App) -> Model { app.new_window().size(250, 200).view(view).build().unwrap(); let start_angle = 0.0; let angle_vel = 0.2; Model { start_angle, angle_vel, } } fn update(_app: &App, model: &mut Model, _update: Update) { ...
Model
identifier_name
allocations.rs
use std::{ collections::HashMap, os::raw::c_void, sync::{ atomic::{AtomicBool, AtomicU64, Ordering::SeqCst}, Mutex, }, }; #[ctor::ctor] unsafe fn initialize_allocation_recording() { tree_sitter::set_allocator( Some(ts_record_malloc), Some(ts_record_calloc), S...
(size: usize) -> *mut c_void { let result = malloc(size); record_alloc(result); result } unsafe extern "C" fn ts_record_calloc(count: usize, size: usize) -> *mut c_void { let result = calloc(count, size); record_alloc(result); result } unsafe extern "C" fn ts_record_realloc(ptr: *mut c_void, s...
ts_record_malloc
identifier_name
allocations.rs
use std::{ collections::HashMap, os::raw::c_void, sync::{ atomic::{AtomicBool, AtomicU64, Ordering::SeqCst}, Mutex, }, }; #[ctor::ctor] unsafe fn initialize_allocation_recording() { tree_sitter::set_allocator( Some(ts_record_malloc), Some(ts_record_calloc), S...
}); } fn record_dealloc(ptr: *mut c_void) { RECORDER.with(|recorder| { if recorder.enabled.load(SeqCst) { recorder .outstanding_allocations .lock() .unwrap() .remove(&Allocation(ptr)); } }); } unsafe extern "C" fn ts_...
{ let count = recorder.allocation_count.fetch_add(1, SeqCst); recorder .outstanding_allocations .lock() .unwrap() .insert(Allocation(ptr), count); }
conditional_block
allocations.rs
use std::{ collections::HashMap, os::raw::c_void, sync::{ atomic::{AtomicBool, AtomicU64, Ordering::SeqCst}, Mutex, }, }; #[ctor::ctor] unsafe fn initialize_allocation_recording() { tree_sitter::set_allocator( Some(ts_record_malloc), Some(ts_record_calloc), S...
fn malloc(size: usize) -> *mut c_void; fn calloc(count: usize, size: usize) -> *mut c_void; fn realloc(ptr: *mut c_void, size: usize) -> *mut c_void; fn free(ptr: *mut c_void); } pub fn record<T>(f: impl FnOnce() -> T) -> T { RECORDER.with(|recorder| { recorder.enabled.store(true, SeqCst); ...
thread_local! { static RECORDER: AllocationRecorder = Default::default(); } extern "C" {
random_line_split
allocations.rs
use std::{ collections::HashMap, os::raw::c_void, sync::{ atomic::{AtomicBool, AtomicU64, Ordering::SeqCst}, Mutex, }, }; #[ctor::ctor] unsafe fn initialize_allocation_recording() { tree_sitter::set_allocator( Some(ts_record_malloc), Some(ts_record_calloc), S...
unsafe extern "C" fn ts_record_malloc(size: usize) -> *mut c_void { let result = malloc(size); record_alloc(result); result } unsafe extern "C" fn ts_record_calloc(count: usize, size: usize) -> *mut c_void { let result = calloc(count, size); record_alloc(result); result } unsafe extern "C" f...
{ RECORDER.with(|recorder| { if recorder.enabled.load(SeqCst) { recorder .outstanding_allocations .lock() .unwrap() .remove(&Allocation(ptr)); } }); }
identifier_body
p122.rs
//! [Problem 122](https://projecteuler.net/problem=122) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use std::u32; fn backtrack(power: u32, depth: u32, limit: u32, cost: &mut [u32], path: &mut [u32]) { if power > ...
}
{ let limit = 15; let cost = super::compute_cost(limit); assert_eq!(5, cost[limit as usize]); }
identifier_body
p122.rs
//! [Problem 122](https://projecteuler.net/problem=122) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use std::u32; fn backtrack(power: u32, depth: u32, limit: u32, cost: &mut [u32], path: &mut [u32]) { if power > ...
cost[power as usize] = depth; path[depth as usize] = power; for i in (0..(depth + 1)).rev() { backtrack(power + path[i as usize], depth + 1, limit, cost, path); } } fn compute_cost(limit: u32) -> Vec<u32> { let mut cost = vec![u32::MAX; (limit + 1) as usize]; let mut path = vec![0; (...
{ return; }
conditional_block
p122.rs
//! [Problem 122](https://projecteuler.net/problem=122) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use std::u32; fn backtrack(power: u32, depth: u32, limit: u32, cost: &mut [u32], path: &mut [u32]) { if power > ...
} }
let limit = 15; let cost = super::compute_cost(limit); assert_eq!(5, cost[limit as usize]);
random_line_split
p122.rs
//! [Problem 122](https://projecteuler.net/problem=122) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use std::u32; fn backtrack(power: u32, depth: u32, limit: u32, cost: &mut [u32], path: &mut [u32]) { if power > ...
() { let limit = 15; let cost = super::compute_cost(limit); assert_eq!(5, cost[limit as usize]); } }
m15
identifier_name
002.rs
// Each new term in the Fibonacci sequence is generated by adding the previous two terms. // By starting with 1 and 2, the first 10 terms will be: // 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,... // By considering the terms in the Fibonacci sequence whose values do not exceed four million, // find the sum of the even-value...
(limit: uint) -> LimitedFibonacci { LimitedFibonacci { limit: limit, last: 1, next: 1, } } } impl Iterator<uint> for LimitedFibonacci { fn next(&mut self) -> Option<uint> { let ret = self.last; self.last = self.next; self.next = self.last + ret; if ret < self.limit { Some(re...
new
identifier_name
002.rs
// Each new term in the Fibonacci sequence is generated by adding the previous two terms. // By starting with 1 and 2, the first 10 terms will be: // 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,... // By considering the terms in the Fibonacci sequence whose values do not exceed four million, // find the sum of the even-value...
} fn compute(limit: uint) -> uint { let mut fibs = LimitedFibonacci::new(limit); fibs.filter(|n| n % 2 == 0) .fold(0, |a, b| a + b) } fn main() { println!("{}", compute(4000000)); }
{ let ret = self.last; self.last = self.next; self.next = self.last + ret; if ret < self.limit { Some(ret) } else { None } }
identifier_body
002.rs
// Each new term in the Fibonacci sequence is generated by adding the previous two terms.
// By considering the terms in the Fibonacci sequence whose values do not exceed four million, // find the sum of the even-valued terms. struct LimitedFibonacci { limit: uint, last: uint, next: uint } impl LimitedFibonacci { fn new(limit: uint) -> LimitedFibonacci { LimitedFibonacci { limit: limit...
// By starting with 1 and 2, the first 10 terms will be: // 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
random_line_split
002.rs
// Each new term in the Fibonacci sequence is generated by adding the previous two terms. // By starting with 1 and 2, the first 10 terms will be: // 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,... // By considering the terms in the Fibonacci sequence whose values do not exceed four million, // find the sum of the even-value...
else { None } } } fn compute(limit: uint) -> uint { let mut fibs = LimitedFibonacci::new(limit); fibs.filter(|n| n % 2 == 0) .fold(0, |a, b| a + b) } fn main() { println!("{}", compute(4000000)); }
{ Some(ret) }
conditional_block
mod.rs
use std::env; use std::fs::{self, File}; use std::io::Read; use std::path::{Path, PathBuf}; use std::sync::Mutex; use super::actor::Actor; use super::{Result, expand, collapse}; lazy_static! { static ref CURRENT_DIR: PathBuf = { let path = fs::canonicalize(Path::new(file!()).parent().unwrap()).unwrap(); ...
() { for entry in fs::read_dir(".").unwrap().map(|e| e.unwrap()) { let path = entry.path(); let path_str = path.to_str().unwrap(); if path_str.contains('_') && path_str.ends_with(".m") { fs::remove_file(&path).unwrap(); } } } fn with_backup<P1: AsRef<Path>, P2: AsRef...
clear
identifier_name
mod.rs
use std::env; use std::fs::{self, File}; use std::io::Read; use std::path::{Path, PathBuf}; use std::sync::Mutex; use super::actor::Actor; use super::{Result, expand, collapse}; lazy_static! { static ref CURRENT_DIR: PathBuf = { let path = fs::canonicalize(Path::new(file!()).parent().unwrap()).unwrap(); ...
test!(expanding { try(expand(Actor::new(), "script.m", false)); for part in &["_0", "a_1", "b_2", "if_true_3", "gen"] { compare(format!("script_{}.m", part), format!("script{}.m", part.replace('_', "")), true); } }); test!(collapsing { with_backup("script.m", "...
{ match res { Ok(_) => {}, Err(e) => panic!("{:?}", e), } }
identifier_body
mod.rs
use std::env; use std::fs::{self, File}; use std::io::Read; use std::path::{Path, PathBuf}; use std::sync::Mutex; use super::actor::Actor; use super::{Result, expand, collapse}; lazy_static! { static ref CURRENT_DIR: PathBuf = { let path = fs::canonicalize(Path::new(file!()).parent().unwrap()).unwrap(); ...
assert_eq!(v1, v2); } fn try<T>(res: Result<T>) { match res { Ok(_) => {}, Err(e) => panic!("{:?}", e), } } test!(expanding { try(expand(Actor::new(), "script.m", false)); for part in &["_0", "a_1", "b_2", "if_true_3", "gen"] { compare(format!("script_{}.m", part), ...
{ v1 = v1.replace(CURRENT_DIR.to_str().unwrap(), "{{dir}}"); }
conditional_block