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 |
|---|---|---|---|---|
mod.rs | use crate::rendering::*;
use crate::geometry::*;
/// IMPORTANT: Must form a star domain at its center
#[derive(Clone, Debug)]
pub struct Polygon {
pub corners: Vec<Point>, /// defined anti-clockwise
pub center: Point,
pub rot: Rotation, /// anti-clockwise angle w.r.t. positive z-axis
pub pos: Point3,
... | )
}
fn get_vertex(self) -> Vec<Self::Vertex> { self.get_vertices() }
}
#[derive(Copy, Clone, Debug)]
pub struct PolygonVertex {
pub corner1: [f32; 2],
pub corner2: [f32; 2],
pub center: [f32; 2],
pub rot: [[f32; 2]; 2],
pub pos: [f32; 3],
pub color: [f32; 4],
pub fixed_pos:... | include_str!("polygon.ges"),
include_str!("polygon.fs") | random_line_split |
mod.rs | use crate::rendering::*;
use crate::geometry::*;
/// IMPORTANT: Must form a star domain at its center
#[derive(Clone, Debug)]
pub struct Polygon {
pub corners: Vec<Point>, /// defined anti-clockwise
pub center: Point,
pub rot: Rotation, /// anti-clockwise angle w.r.t. positive z-axis
pub pos: Point3,
... | {
pub corner1: [f32; 2],
pub corner2: [f32; 2],
pub center: [f32; 2],
pub rot: [[f32; 2]; 2],
pub pos: [f32; 3],
pub color: [f32; 4],
pub fixed_pos: u32
}
implement_vertex!(PolygonVertex, corner1, corner2, center, rot, pos, color, fixed_pos);
| PolygonVertex | identifier_name |
collapsible_match.rs | use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::visitors::LocalUsedVisitor;
use clippy_utils::{higher, is_lang_ctor, is_unit_expr, path_to_local, peel_ref_operators, SpanlessEq};
use if_chain::if_chain;
use rustc_hir::LangItem::OptionNone;
use rustc_hir::{Arm, Expr, ExprKind, Guard, HirId, MatchSou... | (&mut self, cx: &LateContext<'tcx>, expr: &Expr<'tcx>) {
match IfLetOrMatch::parse(cx, expr) {
Some(IfLetOrMatch::Match(_, arms, _)) => {
if let Some(els_arm) = arms.iter().rfind(|arm| arm_is_wild_like(cx, arm)) {
for arm in arms {
check_ar... | check_expr | identifier_name |
collapsible_match.rs | use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::visitors::LocalUsedVisitor;
use clippy_utils::{higher, is_lang_ctor, is_unit_expr, path_to_local, peel_ref_operators, SpanlessEq};
use if_chain::if_chain;
use rustc_hir::LangItem::OptionNone;
use rustc_hir::{Arm, Expr, ExprKind, Guard, HirId, MatchSou... |
}
fn check_arm<'tcx>(
cx: &LateContext<'tcx>,
outer_is_match: bool,
outer_pat: &'tcx Pat<'tcx>,
outer_then_body: &'tcx Expr<'tcx>,
outer_guard: Option<&'tcx Guard<'tcx>>,
outer_else_body: Option<&'tcx Expr<'tcx>>
) {
let inner_expr = strip_singleton_blocks(outer_then_body);
if_chain! {... | {
match IfLetOrMatch::parse(cx, expr) {
Some(IfLetOrMatch::Match(_, arms, _)) => {
if let Some(els_arm) = arms.iter().rfind(|arm| arm_is_wild_like(cx, arm)) {
for arm in arms {
check_arm(cx, true, arm.pat, arm.body, arm.guard.as_ref(), Some... | identifier_body |
collapsible_match.rs | use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::visitors::LocalUsedVisitor;
use clippy_utils::{higher, is_lang_ctor, is_unit_expr, path_to_local, peel_ref_operators, SpanlessEq};
use if_chain::if_chain;
use rustc_hir::LangItem::OptionNone;
use rustc_hir::{Arm, Expr, ExprKind, Guard, HirId, MatchSou... | /// Ok(n) => n,
/// _ => return,
/// }
/// None => return,
/// };
/// }
/// ```
/// Use instead:
/// ```rust
/// fn func(opt: Option<Result<u64, String>>) {
/// let n = match opt {
/// Some(Ok(n)) => n,
/// ... | /// fn func(opt: Option<Result<u64, String>>) {
/// let n = match opt {
/// Some(n) => match n { | random_line_split |
fallback.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::fmt;
use std::sync::Arc;
use anyhow::Error;
use futures::{channel::mpsc::channel, SinkExt, StreamExt, TryStreamExt};
use tracing::e... | <K, VP, VF, VW> {
/// The preferred store, which will always be queried. Usually a local store.
pub preferred: BoxedReadStore<K, VP>,
/// The fallback store, which will be queried if the value is not found in the
/// primary store.
pub fallback: BoxedReadStore<K, VF>,
/// A `WriteStore` to whi... | FallbackCache | identifier_name |
fallback.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::fmt;
use std::sync::Arc;
use anyhow::Error;
use futures::{channel::mpsc::channel, SinkExt, StreamExt, TryStreamExt}; | use crate::scmstore::{
BoxedReadStore, BoxedWriteStore, FetchError, FetchStream, KeyStream, ReadStore,
};
/// A combinator which queries a preferred store, then falls back to a fallback store
/// if a key is not found in the preferred store. Keys fetched from the fallback will
/// be written to the write_store if ... | use tracing::error;
use streams::select_drop;
| random_line_split |
fallback.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::fmt;
use std::sync::Arc;
use anyhow::Error;
use futures::{channel::mpsc::channel, SinkExt, StreamExt, TryStreamExt};
use tracing::e... | },
// TODO(meyer): Should we also fall back on KeyedError, but also log an error?
Err(e) => Some(Err(e)),
}
}
});
let fallback_stream = self
.fallback
.clone()
... | {
// TODO(meyer): Write a custom Stream implementation to try to avoid use of channels
let (sender, receiver) = channel(CHANNEL_BUFFER);
let preferred_stream = self
.preferred
.clone()
.fetch_stream(keys)
.filter_map(move |res| {
l... | identifier_body |
framerate.rs | //! Framerate control
use libc;
use libc::{c_void, size_t};
use std::mem;
use ::get_error;
use sys::gfx;
/// Structure holding the state and timing information of the framerate controller.
pub struct FPSManager {
raw: *mut gfx::framerate::FPSmanager,
}
impl FPSManager {
/// Create the framerate manager.
... | (&self) -> i32 {
// will not get an error
unsafe { gfx::framerate::SDL_getFramerate(self.raw) as i32 }
}
/// Return the current framecount.
pub fn get_frame_count(&self) -> i32 {
// will not get an error
unsafe { gfx::framerate::SDL_getFramecount(self.raw) as i32 }
}
... | get_framerate | identifier_name |
framerate.rs | //! Framerate control
use libc;
use libc::{c_void, size_t};
use std::mem;
use ::get_error;
use sys::gfx;
/// Structure holding the state and timing information of the framerate controller.
pub struct FPSManager {
raw: *mut gfx::framerate::FPSmanager,
}
impl FPSManager {
/// Create the framerate manager.
... |
/// Delay execution to maintain a constant framerate and calculate fps.
pub fn delay(&mut self) -> u32 {
unsafe { gfx::framerate::SDL_framerateDelay(self.raw) as u32 }
}
}
impl Drop for FPSManager {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut c_void) }
}
}
| {
// will not get an error
unsafe { gfx::framerate::SDL_getFramecount(self.raw) as i32 }
} | identifier_body |
framerate.rs | //! Framerate control
use libc;
use libc::{c_void, size_t};
use std::mem;
use ::get_error;
use sys::gfx;
/// Structure holding the state and timing information of the framerate controller.
pub struct FPSManager {
raw: *mut gfx::framerate::FPSmanager, | unsafe {
let size = mem::size_of::<gfx::framerate::FPSmanager>() as size_t;
let raw = libc::malloc(size) as *mut gfx::framerate::FPSmanager;
gfx::framerate::SDL_initFramerate(raw);
FPSManager { raw: raw }
}
}
/// Set the framerate in Hz.
pub f... | }
impl FPSManager {
/// Create the framerate manager.
pub fn new() -> FPSManager { | random_line_split |
ethkey.rs | // Copyright 2015, 2016 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 la... | let expected =
"secret: 17d08f5fe8c77af811caa0c9a187e668ce3b74a99acc3f6d976f075fa8e0be55
public: 689268c0ff57a20cd299fa60d3fb374862aff565b20b5f1767906a99e6e09f3ff04ca2b2a5cd22f62941db103c0356df1a8ed20ce322cab2483db67685afd124
address: 26d1ec50b4e62c1d1a40d16e7cacc6a6580757d5".to_owned();
assert_eq!(execute(comman... | random_line_split | |
ethkey.rs | // Copyright 2015, 2016 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 la... | () {
let command = vec!["ethkey", "info", "17d08f5fe8c77af811caa0c9a187e668ce3b74a99acc3f6d976f075fa8e0be55"]
.into_iter()
.map(Into::into)
.collect::<Vec<String>>();
let expected =
"secret: 17d08f5fe8c77af811caa0c9a187e668ce3b74a99acc3f6d976f075fa8e0be55
public: 689268c0ff57a20cd299fa60d3fb374862aff565... | info | identifier_name |
ethkey.rs | // Copyright 2015, 2016 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 la... |
}
enum DisplayMode {
KeyPair,
Secret,
Public,
Address,
}
impl DisplayMode {
fn new(args: &Args) -> Self {
if args.flag_secret {
DisplayMode::Secret
} else if args.flag_public {
DisplayMode::Public
} else if args.flag_address {
DisplayMode::Address
} else {
DisplayMode::KeyPair
}
}
}
fn m... | {
match *self {
Error::Ethkey(ref e) => write!(f, "{}", e),
Error::FromHex(ref e) => write!(f, "{}", e),
Error::ParseInt(ref e) => write!(f, "{}", e),
}
} | identifier_body |
vec-matching-autoslice.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 x = [1, 2, 3];
match x {
[2, _, _] => panic!(),
[1, a, b] => {
assert!([a, b] == [2, 3]);
}
[_, _, _] => panic!(),
}
let y = ([(1, true), (2, false)], 0.5f64);
match y {
([(1, a), (b, false)], _) => {
assert_eq!(a, true);
... | identifier_body | |
vec-matching-autoslice.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 x = [1, 2, 3];
match x {
[2, _, _] => panic!(),
[1, a, b] => {
assert!([a, b] == [2, 3]);
}
[_, _, _] => panic!(),
}
let y = ([(1, true), (2, false)], 0.5f64);
match y {
([(1, a), (b, false)], _) => {
assert_eq!(a, true);
... | main | identifier_name |
vec-matching-autoslice.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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub fn main() {
let x = [1, 2, 3];
match x {
[2, _, _] => panic!(),
... | random_line_split | |
kindck-inherited-copy-bound.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) {}
}
impl<T:Copy> Foo for T {
}
fn take_param<T:Foo>(foo: &T) { }
fn a() {
let x = box 3;
take_param(&x); //~ ERROR `core::marker::Copy` is not implemented
}
fn b() {
let x = box 3;
let y = &x;
let z = &x as &Foo; //~ ERROR `core::marker::Copy` is not implemented
}
fn main() { }
| foo | identifier_name |
kindck-inherited-copy-bound.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:Copy> Foo for T {
}
fn take_param<T:Foo>(foo: &T) { }
fn a() {
let x = box 3;
take_param(&x); //~ ERROR `core::marker::Copy` is not implemented
}
fn b() {
let x = box 3;
let y = &x;
let z = &x as &Foo; //~ ERROR `core::marker::Copy` is not implemented
}
fn main() { }
| {} | identifier_body |
kindck-inherited-copy-bound.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() { } | random_line_split | |
config.rs | /*
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... |
}
impl<'de> Deserialize<'de> for PortRange {
/// Port ranges can be specified in yaml as either "10" as as single value
/// or as "10-20" as a range, between a minimum and a maximum.
/// This deserializes either format into a [PortRange].
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
... | {
if self.0.start == (self.0.end - 1) {
return serializer.serialize_str(self.0.start.to_string().as_str());
}
let range = format!("{}-{}", self.0.start, self.0.end);
serializer.serialize_str(range.as_str())
} | identifier_body |
config.rs | /*
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... |
self.ports
.iter()
.any(|range| range.contains(&address.port()))
}
}
/// Invalid min and max values for a [PortRange].
#[derive(Debug, thiserror::Error)]
pub enum PortRangeError {
#[error("invalid port range: min {min:?} is greater than or equal to max {max:?}")]
InvalidRang... | {
return false;
} | conditional_block |
config.rs | /*
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... | use schemars::JsonSchema;
use serde::de::{self, Visitor};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use crate::{filters::ConvertProtoConfigError, map_proto_enum};
use super::quilkin::filters::firewall::v1alpha1::{
firewall::{Action as ProtoAction, PortRange as ProtoPortRange, Rule as ProtoRul... | random_line_split | |
config.rs | /*
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... | {
pub action: Action,
/// ipv4 or ipv6 CIDR address.
#[schemars(with = "String")]
pub source: IpNetwork,
pub ports: Vec<PortRange>,
}
impl Rule {
/// Returns `true` if `address` matches the provided CIDR address as well
/// as at least one of the port ranges in the [Rule].
///
/// ... | Rule | identifier_name |
lib.rs | from the address of the struct.
macro_rules! offset_of {
($container:path, $field:ident) => {{
// Make sure the field actually exists. This line ensures that a compile-time error is
// generated if $field is accessed through a Deref impl.
let $container { $field: _,.. };
// Create ... | else {
None
}
}
#[inline]
fn is_unique(&self) -> bool {
// We can use Relaxed here, but the justification is a bit subtle.
//
// The reason to use Acquire would be to synchronize with other threads
// that are modifying the refcount with Release, i.e. to... | {
unsafe {
// See make_mut() for documentation of the threadsafety here.
Some(&mut (*this.ptr()).data)
}
} | conditional_block |
lib.rs | in bytes from the address of the struct.
macro_rules! offset_of {
($container:path, $field:ident) => {{
// Make sure the field actually exists. This line ensures that a compile-time error is
// generated if $field is accessed through a Deref impl.
let $container { $field: _,.. };
/... | impl<H> HeaderWithLength<H> {
/// Creates a new HeaderWithLength.
pub fn new(header: H, length: usize) -> Self {
HeaderWithLength {
header: header,
length: length,
}
}
}
type HeaderSliceWithLength<H, T> = HeaderSlice<HeaderWithLength<H>, T>;
pub struct ThinArc<H:'sta... |
/// The slice length.
length: usize,
}
| random_line_split |
lib.rs | from the address of the struct.
macro_rules! offset_of {
($container:path, $field:ident) => {{
// Make sure the field actually exists. This line ensures that a compile-time error is
// generated if $field is accessed through a Deref impl.
let $container { $field: _,.. };
// Create ... | (&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Pointer::fmt(&self.ptr(), f)
}
}
impl<T:?Sized +'static> fmt::Debug for NonZeroPtrMut<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Pointer>::fmt(self, f)
}
}
impl<T:?Sized +'static> PartialEq for NonZeroPtrM... | fmt | identifier_name |
lib.rs | from the address of the struct.
macro_rules! offset_of {
($container:path, $field:ident) => {{
// Make sure the field actually exists. This line ensures that a compile-time error is
// generated if $field is accessed through a Deref impl.
let $container { $field: _,.. };
// Create ... |
}
impl<T:?Sized +'static> Eq for NonZeroPtrMut<T> {}
pub struct Arc<T:?Sized +'static> {
p: NonZeroPtrMut<ArcInner<T>>,
}
/// An Arc that is known to be uniquely owned
///
/// This lets us build arcs that we can mutate before
/// freezing, without needing to change the allocation
pub struct UniqueArc<T:?Sized +... | {
self.ptr() == other.ptr()
} | identifier_body |
manual_migration.rs | // Copyright 2020 The Exonum Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... | (db: Arc<dyn Database>) {
// Create fork to apply changes to it.
let fork = db.fork();
{
let new_data = Migration::new("test", &fork);
let mut new_schema = v2::Schema::new(new_data.clone());
let old_data = Prefixed::new("test", fork.readonly());
let old_schema = v1::Schema::... | manual_migration | identifier_name |
manual_migration.rs | // Copyright 2020 The Exonum Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... | new_schema.wallets.put(&public_key, new_wallet);
}
if i % 1_000 == 999 {
println!("Processed {} wallets", i + 1);
}
}
}
fn manual_migration(db: Arc<dyn Database>) {
// Create fork to apply changes to it.
let fork = db.fork();
{
let new_data = M... | {
let old_schema = v1::Schema::new(old_data);
let mut new_schema = v2::Schema::new(new_data.clone());
// Migrate wallets.
for (i, (public_key, wallet)) in old_schema.wallets.iter().enumerate() {
if wallet.username == "Eve" {
// We don't like Eves 'round these parts. Remove her trans... | identifier_body |
manual_migration.rs | // Copyright 2020 The Exonum Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
// Migrate wallets.
for (i, (public_key, wallet)) in old_schema.wallets.iter().enumerate() {
if wallet.username == "Eve" {
// We don't like Eves 'round these parts. Remove her transaction history
// and don't migrate the wallet.
new_data.create_tombstone(("histories"... | /// - Wallets and wallet history belonging to the users named "Eve' are dropped.
fn migrate_wallets(new_data: Migration<&Fork>, old_data: Prefixed<ReadonlyFork<'_>>) {
let old_schema = v1::Schema::new(old_data);
let mut new_schema = v2::Schema::new(new_data.clone()); | random_line_split |
manual_migration.rs | // Copyright 2020 The Exonum Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
if i % 1_000 == 999 {
println!("Processed {} wallets", i + 1);
}
}
}
fn manual_migration(db: Arc<dyn Database>) {
// Create fork to apply changes to it.
let fork = db.fork();
{
let new_data = Migration::new("test", &fork);
let mut new_schema = v2::Schema::... | {
// Merkelize the wallet history.
let mut history = new_schema.histories.get(&public_key);
history.extend(&old_schema.histories.get(&public_key));
let new_wallet = v2::Wallet {
username: wallet.username,
balance: wallet.balance,
... | conditional_block |
mod.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::{build, Program};
use graphql_syntax::parse_executable;
... |
}
| {
panic!("Expected exactly one %extensions% section marker.")
} | conditional_block |
mod.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
| use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::get_test_schema_with_extensions;
use relay_transforms::validate_server_only_directives;
use std::sync::Arc;
pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
let parts: Vec... | use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::{build, Program}; | random_line_split |
mod.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::{build, Program};
use graphql_syntax::parse_executable;
... | {
let parts: Vec<_> = fixture.content.split("%extensions%").collect();
if let [base, extensions] = parts.as_slice() {
let source_location = SourceLocationKey::standalone(fixture.file_name);
let ast = parse_executable(base, source_location).unwrap();
let schema = get_test_schema_with_ext... | identifier_body | |
mod.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::{build, Program};
use graphql_syntax::parse_executable;
... | (fixture: &Fixture<'_>) -> Result<String, String> {
let parts: Vec<_> = fixture.content.split("%extensions%").collect();
if let [base, extensions] = parts.as_slice() {
let source_location = SourceLocationKey::standalone(fixture.file_name);
let ast = parse_executable(base, source_location).unwra... | transform_fixture | identifier_name |
lib.rs | #![feature(test)]
extern crate time;
extern crate test;
#[test] |
// pretty print
pub fn pretty_print(e : &str) {
let t = time::now();
let s = time::strftime("%Y-%m-%d %H:%M:%S", &t);
if s.is_ok() {
println!("{0}\t{1}", s.unwrap(), e);
}
else {
println!("####-##-## ##:##:##\t{}", e);
}
}
// mean of array
pub fn mean(a : &[f32]) -> f32 {
let m... | fn it_works() {
} | random_line_split |
lib.rs | #![feature(test)]
extern crate time;
extern crate test;
#[test]
fn it_works() {
}
// pretty print
pub fn pretty_print(e : &str) |
// mean of array
pub fn mean(a : &[f32]) -> f32 {
let mut sum = 0.0;
let mut n = 0.0;
for p in a.iter() {
sum = sum + *p; // need to (*) dereference pointers
n = n + 1.0;
}
let f = sum / n;
return f;
}
// median of array
pub fn median(a : &[f32]) -> f32 {
let l = a.len();
... | {
let t = time::now();
let s = time::strftime("%Y-%m-%d %H:%M:%S", &t);
if s.is_ok() {
println!("{0}\t{1}", s.unwrap(), e);
}
else {
println!("####-##-## ##:##:##\t{}", e);
}
} | identifier_body |
lib.rs | #![feature(test)]
extern crate time;
extern crate test;
#[test]
fn | () {
}
// pretty print
pub fn pretty_print(e : &str) {
let t = time::now();
let s = time::strftime("%Y-%m-%d %H:%M:%S", &t);
if s.is_ok() {
println!("{0}\t{1}", s.unwrap(), e);
}
else {
println!("####-##-## ##:##:##\t{}", e);
}
}
// mean of array
pub fn mean(a : &[f32]) -> f32 {
... | it_works | identifier_name |
lib.rs | #![feature(test)]
extern crate time;
extern crate test;
#[test]
fn it_works() {
}
// pretty print
pub fn pretty_print(e : &str) {
let t = time::now();
let s = time::strftime("%Y-%m-%d %H:%M:%S", &t);
if s.is_ok() |
else {
println!("####-##-## ##:##:##\t{}", e);
}
}
// mean of array
pub fn mean(a : &[f32]) -> f32 {
let mut sum = 0.0;
let mut n = 0.0;
for p in a.iter() {
sum = sum + *p; // need to (*) dereference pointers
n = n + 1.0;
}
let f = sum / n;
return f;
}
// media... | {
println!("{0}\t{1}", s.unwrap(), e);
} | conditional_block |
sph_echo_test.rs | extern crate sphlib;
extern crate libc;
use sphlib::{sph_echo, utils};
#[test]
fn will_be_224_hash() |
#[test]
fn will_be_256_hash() {
let dest = sph_echo::echo256_init_load_close("");
let actual = utils::to_hex_hash(&dest);
assert_eq!("4496cd09d425999aefa75189ee7fd3c97362aa9e4ca898328002d20a4b519788", actual.to_string());
}
#[test]
fn will_be_384_hash() {
let dest = sph_echo::echo384_init_load_cl... | {
let dest = sph_echo::echo224_init_load_close("");
let actual = utils::to_hex_hash(&dest);
assert_eq!("17da087595166f733fff7cdb0bca6438f303d0e00c48b5e7a3075905", actual.to_string());
} | identifier_body |
sph_echo_test.rs | extern crate sphlib;
extern crate libc;
use sphlib::{sph_echo, utils};
#[test]
fn will_be_224_hash() {
let dest = sph_echo::echo224_init_load_close("");
let actual = utils::to_hex_hash(&dest);
assert_eq!("17da087595166f733fff7cdb0bca6438f303d0e00c48b5e7a3075905", actual.to_string());
} | assert_eq!("4496cd09d425999aefa75189ee7fd3c97362aa9e4ca898328002d20a4b519788", actual.to_string());
}
#[test]
fn will_be_384_hash() {
let dest = sph_echo::echo384_init_load_close("");
let actual = utils::to_hex_hash(&dest);
assert_eq!("134040763f840559b84b7a1ae5d6d64fc3659821a789cc64a7f1444c09ee7f81a... |
#[test]
fn will_be_256_hash() {
let dest = sph_echo::echo256_init_load_close("");
let actual = utils::to_hex_hash(&dest); | random_line_split |
sph_echo_test.rs | extern crate sphlib;
extern crate libc;
use sphlib::{sph_echo, utils};
#[test]
fn will_be_224_hash() {
let dest = sph_echo::echo224_init_load_close("");
let actual = utils::to_hex_hash(&dest);
assert_eq!("17da087595166f733fff7cdb0bca6438f303d0e00c48b5e7a3075905", actual.to_string());
}
#[test]
fn | () {
let dest = sph_echo::echo256_init_load_close("");
let actual = utils::to_hex_hash(&dest);
assert_eq!("4496cd09d425999aefa75189ee7fd3c97362aa9e4ca898328002d20a4b519788", actual.to_string());
}
#[test]
fn will_be_384_hash() {
let dest = sph_echo::echo384_init_load_close("");
let actual = uti... | will_be_256_hash | identifier_name |
read.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use crate::repo::AdminRepo;
use anyhow::{Error, Result};
use blobstore::Blobstore;
use context::CoreContext;
use skiplist::{deserialize_ski... | let maybebytes = repo.repo_blobstore.get(ctx, &blobstore_key).await?;
match maybebytes {
Some(bytes) => {
debug!(
logger,
"received {} bytes from blobstore",
bytes.as_bytes().len()
);
let bytes = bytes.into_raw_bytes();
... | ctx: &CoreContext,
repo: &AdminRepo,
logger: &Logger,
blobstore_key: String,
) -> Result<Option<SkiplistIndex>, Error> { | random_line_split |
read.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use crate::repo::AdminRepo;
use anyhow::{Error, Result};
use blobstore::Blobstore;
use context::CoreContext;
use skiplist::{deserialize_ski... | {
let maybebytes = repo.repo_blobstore.get(ctx, &blobstore_key).await?;
match maybebytes {
Some(bytes) => {
debug!(
logger,
"received {} bytes from blobstore",
bytes.as_bytes().len()
);
let bytes = bytes.into_raw_bytes()... | identifier_body | |
read.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use crate::repo::AdminRepo;
use anyhow::{Error, Result};
use blobstore::Blobstore;
use context::CoreContext;
use skiplist::{deserialize_ski... | (
ctx: &CoreContext,
repo: &AdminRepo,
logger: &Logger,
blobstore_key: String,
) -> Result<Option<SkiplistIndex>, Error> {
let maybebytes = repo.repo_blobstore.get(ctx, &blobstore_key).await?;
match maybebytes {
Some(bytes) => {
debug!(
logger,
... | get_skiplist_index | identifier_name |
read.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use crate::repo::AdminRepo;
use anyhow::{Error, Result};
use blobstore::Blobstore;
use context::CoreContext;
use skiplist::{deserialize_ski... |
};
Ok(())
}
pub async fn get_skiplist_index(
ctx: &CoreContext,
repo: &AdminRepo,
logger: &Logger,
blobstore_key: String,
) -> Result<Option<SkiplistIndex>, Error> {
let maybebytes = repo.repo_blobstore.get(ctx, &blobstore_key).await?;
match maybebytes {
Some(bytes) => {
... | {
info!(logger, "skiplist not found");
} | conditional_block |
frame.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 msg::constellation_msg::{FrameId, PipelineId};
use pipeline::Pipeline;
use script_traits::LoadData;
use std::c... | };
let frame = match self.frames.get(&frame_id) {
Some(frame) => frame,
None => {
warn!("Frame {:?} iterated after closure.", frame_id);
continue;
},
};
let child_frame_ids = frame.pre... | let pipelines = self.pipelines;
loop {
let frame_id = match self.stack.pop() {
Some(frame_id) => frame_id,
None => return None, | random_line_split |
frame.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 msg::constellation_msg::{FrameId, PipelineId};
use pipeline::Pipeline;
use script_traits::LoadData;
use std::c... | (&mut self) -> Vec<FrameState> {
replace(&mut self.next, vec!())
}
/// Update the current entry of the Frame from an entry that has been traversed to.
pub fn update_current(&mut self, pipeline_id: PipelineId, entry: FrameState) {
self.pipeline_id = pipeline_id;
self.instant = entry.... | remove_forward_entries | identifier_name |
mutex.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 (tx, rx) = channel();
for _ in range(0, K) {
let tx2 = tx.clone();
spawn(proc() { inc(); tx2.send(()); });
let tx2 = tx.clone();
spawn(proc() { inc(); tx2.send(()); });
}
drop(tx);
for _ in range(0, 2 * K) {
rx.rec... | }
} | random_line_split |
mutex.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 ... | (guard: mutex::LockGuard) -> Guard {
Guard { guard: guard }
}
/// Static initialization of a mutex. This constant can be used to initialize
/// other mutex constants.
pub const MUTEX_INIT: StaticMutex = StaticMutex {
lock: mutex::NATIVE_MUTEX_INIT
};
impl StaticMutex {
/// Attempts to grab this lock, see ... | lift_guard | identifier_name |
dom.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/. */
//! Types and traits used to access the DOM from style calculation.
#![allow(unsafe_code)]
use {Atom, Namespace,... | <C: DomTraversalContext<Self::ConcreteNode>>(&self, hint: RestyleHint) {
// Bail early if there's no restyling to do.
if hint.is_empty() {
return;
}
// If the restyle hint is non-empty, we need to restyle either this element
// or one of its siblings. Mark our ancest... | note_restyle_hint | identifier_name |
dom.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/. */
//! Types and traits used to access the DOM from style calculation.
#![allow(unsafe_code)]
use {Atom, Namespace,... | .get_box().clone_display() == display::T::none
}
/// Returns true if this node has a styled layout frame that owns the style.
fn frame_has_style(&self) -> bool { false }
/// Returns the styles from the layout frame that owns them, if any.
///
/// FIXME(bholley): Once we start droppi... | /// Returns true if this element's current style is display:none. Only valid
/// to call after styling.
fn is_display_none(&self) -> bool {
self.borrow_data().unwrap()
.current_styles().primary | random_line_split |
dom.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/. */
//! Types and traits used to access the DOM from style calculation.
#![allow(unsafe_code)]
use {Atom, Namespace,... |
}
pub struct LayoutIterator<T>(pub T);
impl<T, I> Iterator for LayoutIterator<T> where T: Iterator<Item=I>, I: NodeInfo {
type Item = I;
fn next(&mut self) -> Option<I> {
loop {
// Filter out nodes that layout should ignore.
let n = self.0.next();
if n.is_none() || ... | { self.is_element() || self.is_text_node() } | identifier_body |
mod.rs | pub fn solve(input: &String) -> String {
let input = input.lines().nth(0).unwrap().to_string();
format!(
"Skip 1: {} Skip n/2: {}",
_solve(&input, &1),
_solve(&input, &(input.len() / 2))
)
}
fn _solve(input: &String, skip: &usize) -> usize {
let nums: Vec<usize> = input.chars()... | () {
assert_eq!(day1::_solve(&"1111".to_string(), &1), 4);
}
#[test]
fn test_p1_3() {
assert_eq!(day1::_solve(&"1234".to_string(), &1), 0);
}
#[test]
fn test_p1_4() {
assert_eq!(day1::_solve(&"91212129".to_string(), &1), 9);
}
#[test]
fn test_p2_1() {
... | test_p1_2 | identifier_name |
mod.rs | pub fn solve(input: &String) -> String {
let input = input.lines().nth(0).unwrap().to_string();
format!(
"Skip 1: {} Skip n/2: {}",
_solve(&input, &1),
_solve(&input, &(input.len() / 2))
)
}
fn _solve(input: &String, skip: &usize) -> usize {
let nums: Vec<usize> = input.chars()... | #[test]
fn test_p1_2() {
assert_eq!(day1::_solve(&"1111".to_string(), &1), 4);
}
#[test]
fn test_p1_3() {
assert_eq!(day1::_solve(&"1234".to_string(), &1), 0);
}
#[test]
fn test_p1_4() {
assert_eq!(day1::_solve(&"91212129".to_string(), &1), 9);
}
#[test... | }
| random_line_split |
mod.rs | pub fn solve(input: &String) -> String {
let input = input.lines().nth(0).unwrap().to_string();
format!(
"Skip 1: {} Skip n/2: {}",
_solve(&input, &1),
_solve(&input, &(input.len() / 2))
)
}
fn _solve(input: &String, skip: &usize) -> usize {
let nums: Vec<usize> = input.chars()... |
}
sum
}
#[cfg(test)]
mod test {
use day1;
#[test]
fn test_p1_1() {
assert_eq!(day1::_solve(&"1122".to_string(), &1), 3);
}
#[test]
fn test_p1_2() {
assert_eq!(day1::_solve(&"1111".to_string(), &1), 4);
}
#[test]
fn test_p1_3() {
assert_eq!(day1::... | {
sum += nums[i];
} | conditional_block |
mod.rs | pub fn solve(input: &String) -> String {
let input = input.lines().nth(0).unwrap().to_string();
format!(
"Skip 1: {} Skip n/2: {}",
_solve(&input, &1),
_solve(&input, &(input.len() / 2))
)
}
fn _solve(input: &String, skip: &usize) -> usize {
let nums: Vec<usize> = input.chars()... |
#[test]
fn test_p2_1() {
assert_eq!(day1::_solve(&"1212".to_string(), &2), 6);
}
#[test]
fn test_p2_2() {
assert_eq!(day1::_solve(&"1221".to_string(), &2), 0);
}
#[test]
fn test_p2_3() {
assert_eq!(day1::_solve(&"123425".to_string(), &3), 4);
}
#[test... | {
assert_eq!(day1::_solve(&"91212129".to_string(), &1), 9);
} | identifier_body |
socket.rs | /* Rust doesn't have unix datagram socket support at the moment. Hope I can ditch
* this in the future.
* Thanks to @gcourier for his rust-syslog library which I used as a reference. */
use libc;
use std::ffi::CString;
use std::io::{Result, Error, ErrorKind};
use std::mem;
use std::os::unix::io::RawFd;
fn construct... |
}
| {
let (dst, len) = try!(construct_sockaddr(path));
let dstp = &dst as *const libc::sockaddr_storage;
let ret = unsafe { libc::sendto(self.fd,
buf.as_ptr() as *const libc::c_void,
buf.len() as libc::size_t,
... | identifier_body |
socket.rs | /* Rust doesn't have unix datagram socket support at the moment. Hope I can ditch
* this in the future.
* Thanks to @gcourier for his rust-syslog library which I used as a reference. */
use libc;
use std::ffi::CString;
use std::io::{Result, Error, ErrorKind};
use std::mem;
use std::os::unix::io::RawFd;
fn construct... |
s.sun_family = libc::AF_UNIX as libc::sa_family_t;
for (slot, value) in s.sun_path.iter_mut().zip(path.as_bytes().iter()) {
*slot = *value as i8;
}
let len = mem::size_of::<libc::sa_family_t>() + len + 1;
return Ok((storage, len));
}
fn unix_socket(ty: libc::c_int) -> Result<RawFd> {
... | {
let err = Error::new(ErrorKind::InvalidInput,
"Socket path can not be longer than sizeof(sockaddr_storage) - 1");
return Err(err);
} | conditional_block |
socket.rs | /* Rust doesn't have unix datagram socket support at the moment. Hope I can ditch
* this in the future.
* Thanks to @gcourier for his rust-syslog library which I used as a reference. */
use libc;
use std::ffi::CString;
use std::io::{Result, Error, ErrorKind};
use std::mem;
use std::os::unix::io::RawFd;
fn construct... | return Err(err);
}
s.sun_family = libc::AF_UNIX as libc::sa_family_t;
for (slot, value) in s.sun_path.iter_mut().zip(path.as_bytes().iter()) {
*slot = *value as i8;
}
let len = mem::size_of::<libc::sa_family_t>() + len + 1;
return Ok((storage, len));
}
fn unix_socket(ty: lib... | if len > s.sun_path.len() - 1 {
let err = Error::new(ErrorKind::InvalidInput,
"Socket path can not be longer than sizeof(sockaddr_storage) - 1"); | random_line_split |
socket.rs | /* Rust doesn't have unix datagram socket support at the moment. Hope I can ditch
* this in the future.
* Thanks to @gcourier for his rust-syslog library which I used as a reference. */
use libc;
use std::ffi::CString;
use std::io::{Result, Error, ErrorKind};
use std::mem;
use std::os::unix::io::RawFd;
fn | (path: &CString) -> Result<(libc::sockaddr_storage, usize)> {
assert!(mem::size_of::<libc::sockaddr_storage>() >=
mem::size_of::<libc::sockaddr_un>());
let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() };
let s: &mut libc::sockaddr_un = unsafe { mem::transmute(&mut storage) };
... | construct_sockaddr | identifier_name |
mod.rs | // Copyright 2017 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in... |
let key: String = self
.client
.get(
retry::Raw,
AwsProvider::endpoint_for(
&format!("meta-data/public-keys/{}/openssh-key", tokens[0]),
false,
... | {
return Err("error parsing keyID".into());
} | conditional_block |
mod.rs | // Copyright 2017 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in... |
#[derive(Clone, Debug)]
pub struct AwsProvider {
client: retry::Client,
}
impl AwsProvider {
pub fn try_new() -> Result<AwsProvider> {
let client = retry::Client::try_new()?.return_on_404(true);
AwsProvider::with_client(client)
}
fn with_client(client: retry::Client) -> Result<AwsProv... | random_line_split | |
mod.rs | // Copyright 2017 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in... | (key: &str, _use_latest: bool) -> String {
let url = mockito::server_url();
format!("{}/{}", url, key)
}
#[cfg(not(test))]
fn endpoint_for(key: &str, use_latest: bool) -> String {
const URL: &str = "http://169.254.169.254/2019-10-01";
const URL_LATEST: &str = "http://169.254... | endpoint_for | identifier_name |
mod.rs | // Copyright 2017 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in... |
#[cfg(not(test))]
fn endpoint_for(key: &str, use_latest: bool) -> String {
const URL: &str = "http://169.254.169.254/2019-10-01";
const URL_LATEST: &str = "http://169.254.169.254/latest";
if use_latest {
format!("{}/{}", URL_LATEST, key)
} else {
format!... | {
let url = mockito::server_url();
format!("{}/{}", url, key)
} | identifier_body |
mod.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::marker::PhantomData;
use std::sync::Arc;
use async_trait::async_trait;
use edenapi::BlockingResponse;
use edenapi::EdenApi;
use e... | use types::Key;
use crate::datastore::HgIdMutableDeltaStore;
use crate::datastore::RemoteDataStore;
use crate::historystore::HgIdMutableHistoryStore;
use crate::historystore::RemoteHistoryStore;
use crate::remotestore::HgIdRemoteStore;
use crate::types::StoreKey;
mod data;
mod history;
use data::EdenApiDataStore;
us... | use edenapi_types::FileResponse;
use edenapi_types::FileSpec;
use edenapi_types::TreeAttributes;
use edenapi_types::TreeEntry; | random_line_split |
mod.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::marker::PhantomData;
use std::sync::Arc;
use async_trait::async_trait;
use edenapi::BlockingResponse;
use edenapi::EdenApi;
use e... |
fn historystore(
self: Arc<Self>,
_store: Arc<dyn HgIdMutableHistoryStore>,
) -> Arc<dyn RemoteHistoryStore> {
unimplemented!("EdenAPI does not support fetching tree history")
}
}
/// Marker type indicating that the store fetches file data.
pub enum File {}
/// Marker type indica... | {
Arc::new(EdenApiDataStore::new(self, store))
} | identifier_body |
mod.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::marker::PhantomData;
use std::sync::Arc;
use async_trait::async_trait;
use edenapi::BlockingResponse;
use edenapi::EdenApi;
use e... | (client: Arc<dyn EdenApi>) -> Arc<Self> {
Arc::new(Self {
client,
_phantom: PhantomData,
})
}
}
impl HgIdRemoteStore for EdenApiRemoteStore<File> {
fn datastore(
self: Arc<Self>,
store: Arc<dyn HgIdMutableDeltaStore>,
) -> Arc<dyn RemoteDataStore> {
... | new | identifier_name |
coherence-overlap-issue-23516-inherent.rs | // Copyright 2015 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) { } }
fn main() { }
| dummy | identifier_name |
coherence-overlap-issue-23516-inherent.rs | // Copyright 2015 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 Cake<X>(X);
impl<T:Sugar> Cake<T> { fn dummy(&self) { } }
//~^ ERROR E0592
impl<U:Sugar> Cake<Box<U>> { fn dummy(&self) { } }
fn main() { } | // though we see no impl of `Sugar` for `Box`. Therefore, an overlap
// error is reported for the following pair of impls (#23516).
pub trait Sugar {} | random_line_split |
read_pool.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
//! Distinct thread pools to handle read commands having different priority levels.
use crate::config::StorageReadPoolConfig;
use crate::storage::kv::{destroy_tls_engine, set_tls_engine, Engine, FlowStatsReporter};
use crate::storage::metrics;
use fil... | destroy_tls_engine::<E>();
})
.build_future_pool()
})
.collect()
}
/// Build a thread pool that has default tick behavior for testing.
pub fn build_read_pool_for_test<E: Engine>(
config: &StorageReadPoolConfig,
engine: E,
) -> Vec<FuturePool> {... | {
let names = vec!["store-read-low", "store-read-normal", "store-read-high"];
let configs: Vec<Config> = config.to_yatp_pool_configs();
assert_eq!(configs.len(), 3);
configs
.into_iter()
.zip(names)
.map(|(config, name)| {
let reporter = reporter.clone();
... | identifier_body |
read_pool.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
//! Distinct thread pools to handle read commands having different priority levels.
use crate::config::StorageReadPoolConfig;
use crate::storage::kv::{destroy_tls_engine, set_tls_engine, Engine, FlowStatsReporter};
use crate::storage::metrics;
use fil... |
configs
.into_iter()
.zip(names)
.map(|(config, name)| {
let reporter = reporter.clone();
let engine = Arc::new(Mutex::new(engine.clone()));
YatpPoolBuilder::new(FuturePoolTicker { reporter })
.name_prefix(name)
.config(config)
... | engine: E,
) -> Vec<FuturePool> {
let names = vec!["store-read-low", "store-read-normal", "store-read-high"];
let configs: Vec<Config> = config.to_yatp_pool_configs();
assert_eq!(configs.len(), 3); | random_line_split |
read_pool.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
//! Distinct thread pools to handle read commands having different priority levels.
use crate::config::StorageReadPoolConfig;
use crate::storage::kv::{destroy_tls_engine, set_tls_engine, Engine, FlowStatsReporter};
use crate::storage::metrics;
use fil... | <E: Engine, R: FlowStatsReporter>(
config: &StorageReadPoolConfig,
reporter: R,
engine: E,
) -> Vec<FuturePool> {
let names = vec!["store-read-low", "store-read-normal", "store-read-high"];
let configs: Vec<Config> = config.to_yatp_pool_configs();
assert_eq!(configs.len(), 3);
configs
... | build_read_pool | identifier_name |
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 https://mozilla.org/MPL/2.0/. */
#[macro_use]
extern crate malloc_size_of_derive;
use app_units::{Au, MAX_AU, MIN_AU};
use euclid::{
default:... | () -> Rect<Au> {
Rect::new(
Point2D::new(MIN_AU / 2, MIN_AU / 2),
Size2D::new(MAX_AU, MAX_AU),
)
}
}
impl MaxRect for LayoutRect {
fn max_rect() -> LayoutRect {
LayoutRect::new(
LayoutPoint::new(f32::MIN / 2.0, f32::MIN / 2.0),
LayoutSize:... | max_rect | identifier_name |
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 https://mozilla.org/MPL/2.0/. */
#[macro_use]
extern crate malloc_size_of_derive;
use app_units::{Au, MAX_AU, MIN_AU};
use euclid::{
default:... | LayoutSize::new(f32::MAX, f32::MAX),
)
}
}
/// A helper function to convert a rect of `f32` pixels to a rect of app units.
pub fn f32_rect_to_au_rect(rect: Rect<f32>) -> Rect<Au> {
Rect::new(
Point2D::new(
Au::from_f32_px(rect.origin.x),
Au::from_f32_px(rect.... | LayoutRect::new(
LayoutPoint::new(f32::MIN / 2.0, f32::MIN / 2.0), | random_line_split |
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 https://mozilla.org/MPL/2.0/. */
#[macro_use]
extern crate malloc_size_of_derive;
use app_units::{Au, MAX_AU, MIN_AU};
use euclid::{
default:... |
}
impl MaxRect for LayoutRect {
fn max_rect() -> LayoutRect {
LayoutRect::new(
LayoutPoint::new(f32::MIN / 2.0, f32::MIN / 2.0),
LayoutSize::new(f32::MAX, f32::MAX),
)
}
}
/// A helper function to convert a rect of `f32` pixels to a rect of app units.
pub fn f32_rect_t... | {
Rect::new(
Point2D::new(MIN_AU / 2, MIN_AU / 2),
Size2D::new(MAX_AU, MAX_AU),
)
} | identifier_body |
inotify.rs | //! Monitoring API for filesystem events.
//!
//! Inotify is a Linux-only API to monitor filesystems events.
//!
//! For more documentation, please read [inotify(7)](https://man7.org/linux/man-pages/man7/inotify.7.html).
//!
//! # Examples
//!
//! Monitor all events happening in directory "test":
//! ```no_run
//! # us... |
}
| {
Inotify { fd }
} | identifier_body |
inotify.rs | //! Monitoring API for filesystem events.
//!
//! Inotify is a Linux-only API to monitor filesystems events.
//!
//! For more documentation, please read [inotify(7)](https://man7.org/linux/man-pages/man7/inotify.7.html).
//!
//! # Examples
//!
//! Monitor all events happening in directory "test":
//! ```no_run
//! # us... |
};
events.push(InotifyEvent {
wd: WatchDescriptor { wd: event.wd },
mask: AddWatchFlags::from_bits_truncate(event.mask),
cookie: event.cookie,
name
});
offset += header_size + event.len as usize;
}... | {
let ptr = unsafe {
buffer
.as_ptr()
.add(offset + header_size)
as *const c_char
};
let cstr = unsafe { CStr::from_ptr(ptr) };
Som... | conditional_block |
inotify.rs | //! Monitoring API for filesystem events.
//!
//! Inotify is a Linux-only API to monitor filesystems events.
//!
//! For more documentation, please read [inotify(7)](https://man7.org/linux/man-pages/man7/inotify.7.html).
//!
//! # Examples
//!
//! Monitor all events happening in directory "test":
//! ```no_run
//! # us... | {
/// Watch descriptor. This field corresponds to the watch descriptor you
/// were issued when calling add_watch. It allows you to know which watch
/// this event comes from.
pub wd: WatchDescriptor,
/// Event mask. This field is a bitfield describing the exact event that
/// occured.
pub ... | InotifyEvent | identifier_name |
inotify.rs | //! Monitoring API for filesystem events.
//!
//! Inotify is a Linux-only API to monitor filesystems events.
//!
//! For more documentation, please read [inotify(7)](https://man7.org/linux/man-pages/man7/inotify.7.html).
//!
//! # Examples
//!
//! Monitor all events happening in directory "test":
//! ```no_run
//! # us... | pub mask: AddWatchFlags,
/// This cookie is a number that allows you to connect related events. For
/// now only IN_MOVED_FROM and IN_MOVED_TO can be connected.
pub cookie: u32,
/// Filename. This field exists only if the event was triggered for a file
/// inside the watched directory.
pub n... | /// were issued when calling add_watch. It allows you to know which watch
/// this event comes from.
pub wd: WatchDescriptor,
/// Event mask. This field is a bitfield describing the exact event that
/// occured. | random_line_split |
error.rs | //! Postgres errors
use std::collections::HashMap;
use std::io;
use std::fmt;
use openssl::ssl::error;
use phf::PhfMap;
use PostgresResult;
use types::PostgresType;
macro_rules! make_errors(
($($code:expr => $error:ident),+) => (
/// SQLSTATE error codes
#[deriving(PartialEq, Eq, Clone, Show)]
... | /// or WARNING, NOTICE, DEBUG, INFO, or LOG (in a notice message), or a
/// localized translation of one of these.
pub severity: String,
/// The SQLSTATE code for the error.
pub code: PostgresSqlState,
/// The primary human-readable error message. This should be accurate but
/// terse (typically... | message),
| identifier_name |
error.rs | //! Postgres errors
use std::collections::HashMap;
use std::io;
use std::fmt;
use openssl::ssl::error;
use phf::PhfMap;
use PostgresResult;
use types::PostgresType;
macro_rules! make_errors(
($($code:expr => $error:ident),+) => (
/// SQLSTATE error codes
#[deriving(PartialEq, Eq, Clone, Show)]
... | "2F003" => ProhibitedSqlStatementAttemptedSqlRoutine,
"2F004" => ReadingSqlDataNotPermittedSqlRoutine,
// Class 34 — Invalid Cursor Name
"34000" => InvalidCursorName,
// Class 38 — External Routine Exception
"38000" => ExternalRoutineException,
"38001" => ContainingSqlNotPermitted,
"38... | "2F002" => ModifyingSqlDataNotPermittedSqlRoutine, | random_line_split |
error.rs | //! Postgres errors
use std::collections::HashMap;
use std::io;
use std::fmt;
use openssl::ssl::error;
use phf::PhfMap;
use PostgresResult;
use types::PostgresType;
macro_rules! make_errors(
($($code:expr => $error:ident),+) => (
/// SQLSTATE error codes
#[deriving(PartialEq, Eq, Clone, Show)]
... | Clone, PartialEq, Eq)]
pub enum PostgresError {
/// An error reported by the Postgres server
PgDbError(PostgresDbError),
/// An error communicating with the Postgres server
PgStreamError(io::IoError),
/// The communication channel with the Postgres server has desynchronized
/// due to an earlier... | ncountered when communicating with the Postgres server
#[deriving( | identifier_body |
main.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#![warn(clippy::all)]
mod client;
mod error_reporting;
mod lsp;
mod server;
use lsp_server::Connection;
use std::error::Error;
us... | }
}
| {
// Test with an in-memory connection pair
let (connection, client) = Connection::memory();
// Mock set of client parameters. The `root_path` field is deprecated, but
// still required to construct the params, so we allow deprecated fields here.
#[allow(deprecated)]
let ... | identifier_body |
main.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
|
mod client;
mod error_reporting;
mod lsp;
mod server;
use lsp_server::Connection;
use std::error::Error;
use env_logger::Env;
use log::info;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Sync + Send>> {
env_logger::from_env(Env::default().default_filter_or("info, warn, error, debug")).init();
... | #![warn(clippy::all)] | random_line_split |
main.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#![warn(clippy::all)]
mod client;
mod error_reporting;
mod lsp;
mod server;
use lsp_server::Connection;
use std::error::Error;
us... | () -> Result<(), Box<dyn Error + Sync + Send>> {
env_logger::from_env(Env::default().default_filter_or("info, warn, error, debug")).init();
let (connection, io_handles) = Connection::stdio();
info!("Initialized stdio transport layer");
let params = server::initialize(&connection)?;
info!("JSON-RPC h... | main | identifier_name |
borrowck-move-out-of-tuple-struct-with-dtor.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 ... | match S("foo".to_owned()) {
S(_s) => {}
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
}
}
fn move_in_let() {
let S(_s) = S("foo".to_owned());
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
}
fn move_in_fn_arg(S(_s): S) {
//~^ ERROR c... | }
fn move_in_match() { | random_line_split |
borrowck-move-out-of-tuple-struct-with-dtor.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 ... | (&mut self) { }
}
fn move_in_match() {
match S("foo".to_owned()) {
S(_s) => {}
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
}
}
fn move_in_let() {
let S(_s) = S("foo".to_owned());
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
}
fn mov... | drop | identifier_name |
borrowck-move-out-of-tuple-struct-with-dtor.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 ... | {} | identifier_body | |
deactivate.rs | //! `POST /_matrix/client/*/account/deactivate`
pub mod v3 {
//! `/v3/` ([spec])
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3accountdeactivate
use ruma_common::api::ruma_api;
use crate::{
account::ThirdPartyIdRemovalStatus,
uiaa::{AuthData, I... |
#[derive(Default)]
request: {
/// Additional authentication information for the user-interactive authentication API.
#[serde(skip_serializing_if = "Option::is_none")]
pub auth: Option<AuthData<'a>>,
/// Identity server from which to unbind the user's thi... | rate_limited: true,
authentication: AccessToken,
added: 1.0,
} | random_line_split |
deactivate.rs | //! `POST /_matrix/client/*/account/deactivate`
pub mod v3 {
//! `/v3/` ([spec])
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3accountdeactivate
use ruma_common::api::ruma_api;
use crate::{
account::ThirdPartyIdRemovalStatus,
uiaa::{AuthData, I... |
}
}
| {
Self { id_server_unbind_result }
} | identifier_body |
deactivate.rs | //! `POST /_matrix/client/*/account/deactivate`
pub mod v3 {
//! `/v3/` ([spec])
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3accountdeactivate
use ruma_common::api::ruma_api;
use crate::{
account::ThirdPartyIdRemovalStatus,
uiaa::{AuthData, I... | (id_server_unbind_result: ThirdPartyIdRemovalStatus) -> Self {
Self { id_server_unbind_result }
}
}
}
| new | identifier_name |
stmt_parse.rs | use std::path::PathBuf;
use syntax_tree::*;
use parser::lexer::lexer_util::lexemes::*;
use parser::syntax_parser::expr_parse::*;
use parser::syntax_parser::synpar_util::*;
use error::{RollerErr, SynErr, ParseResult};
#[allow(unused_variables)]
pub fn parse_stmt(input: InType) -> ParseResult<Stmt> {
Err(())
.or(pars... |
fn parse_run(input: InType) -> ParseResult<Stmt, ()> {
if let Some((&Lexeme::Kw(KwToken::Run), input)) = input.split_first() {
if let Some((&Lexeme::Id(ref s), input)) = input.split_first() {
if input.get(0) == Some(&Lexeme::End) {
return Ok(Stmt::Run(PathBuf::from(s) ));
}
}
}
Err(())
}
fn parse_sa... | {
if input.len() == 2 { // clear, end
if let Lexeme::Kw(KwToken::Clear) = input[0] {
return Ok(Stmt::Clear);
}
}
Err(())
} | identifier_body |
stmt_parse.rs | use std::path::PathBuf;
use syntax_tree::*;
use parser::lexer::lexer_util::lexemes::*;
use parser::syntax_parser::expr_parse::*;
use parser::syntax_parser::synpar_util::*;
use error::{RollerErr, SynErr, ParseResult};
#[allow(unused_variables)]
pub fn parse_stmt(input: InType) -> ParseResult<Stmt> {
Err(())
.or(pars... | if let Some((&Lexeme::Kw(KwToken::Save), input)) = input.split_first() {
if let Some((&Lexeme::Id(ref s), input)) = input.split_first() {
if input.get(0) == Some(&Lexeme::End) {
return Ok(Stmt::Save(PathBuf::from(s) ));
}
}
}
Err(())
} | random_line_split | |
stmt_parse.rs | use std::path::PathBuf;
use syntax_tree::*;
use parser::lexer::lexer_util::lexemes::*;
use parser::syntax_parser::expr_parse::*;
use parser::syntax_parser::synpar_util::*;
use error::{RollerErr, SynErr, ParseResult};
#[allow(unused_variables)]
pub fn | (input: InType) -> ParseResult<Stmt> {
Err(())
.or(parse_assign(input))
.or(parse_fundef(input))
.or(parse_delete(input))
.or(parse_clear(input))
.or(parse_run(input))
.or(parse_save(input))
.or(Err(RollerErr::SyntaxError(SynErr::Unimplemented)))
}
fn parse_assign(input: InType) -> ParseResult<Stmt, ()> {
// ... | parse_stmt | identifier_name |
stmt_parse.rs | use std::path::PathBuf;
use syntax_tree::*;
use parser::lexer::lexer_util::lexemes::*;
use parser::syntax_parser::expr_parse::*;
use parser::syntax_parser::synpar_util::*;
use error::{RollerErr, SynErr, ParseResult};
#[allow(unused_variables)]
pub fn parse_stmt(input: InType) -> ParseResult<Stmt> {
Err(())
.or(pars... |
}
}
Err(())
}
fn parse_fundef(input: InType) -> ParseResult<Stmt, ()> {
if let Some((&Lexeme::Id(ref id), input)) = input.split_first() {
if let Some((&Lexeme::LeftParen, input)) = input.split_first() {
// parse parameters
let mut mut_input = input.clone();
let mut param_ids = Vec::new();
loop {
... | {
return Ok(Stmt::Assign(id.clone(), exp));
} | conditional_block |
headless_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 https://mozilla.org/MPL/2.0/. */
//! A headless window implementation.
use crate::window_trait::WindowPortsMethods;
use glutin;
use euclid::{defa... |
}
pub struct Window {
context: HeadlessContext,
animation_state: Cell<AnimationState>,
fullscreen: Cell<bool>,
gl: Rc<dyn gl::Gl>,
}
impl Window {
pub fn new(size: Size2D<u32, DeviceIndependentPixel>) -> Rc<dyn WindowPortsMethods> {
let context = HeadlessContext::new(size.width, size.heig... | {
ptr::null() as *const _
} | identifier_body |
headless_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 https://mozilla.org/MPL/2.0/. */
//! A headless window implementation.
use crate::window_trait::WindowPortsMethods;
use glutin;
use euclid::{defa... | (s: &str) -> *const c_void {
let c_str = CString::new(s).expect("Unable to create CString");
unsafe { mem::transmute(osmesa_sys::OSMesaGetProcAddress(c_str.as_ptr())) }
}
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
fn get_proc_address(_: &str) -> *const c_void {
ptr::... | get_proc_address | identifier_name |
headless_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 https://mozilla.org/MPL/2.0/. */
//! A headless window implementation.
use crate::window_trait::WindowPortsMethods;
use glutin;
use euclid::{defa... |
fn servo_hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel> {
match opts::get().device_pixels_per_px {
Some(device_pixels_per_px) => Scale::new(device_pixels_per_px),
_ => Scale::new(1.0),
}
}
}
impl WindowPortsMethods for Window {
fn get_events(... |
Rc::new(window)
} | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.