hexsha stringlengths 40 40 | size int64 4 1.05M | content stringlengths 4 1.05M | avg_line_length float64 1.33 100 | max_line_length int64 1 1k | alphanum_fraction float64 0.25 1 |
|---|---|---|---|---|---|
f8449c6ec1255a7079b2ceccb4eb8ffb15b5c454 | 3,047 | use crate::avm1::activation::Activation;
use crate::avm1::error::Error;
use crate::avm1::object::Object;
use crate::avm1::property_decl::{define_properties_on, Declaration};
use crate::avm1::{AvmString, ScriptObject, Value};
use crate::avm_warn;
use gc_arena::MutationContext;
use std::convert::Into;
const OBJECT_DECLS... | 28.476636 | 76 | 0.643256 |
d5acf82207dc7bed424ea5827b4973a662497e5c | 544 | use super::*;
use windows::{core::*, UI::ViewManagement::*};
fn accent_impl() -> Result<Color> {
let settings = UISettings::new()?;
let accent = settings.GetColorValue(UIColorType::Accent)?;
Ok(Color {
r: accent.R,
g: accent.G,
b: accent.B,
})
}
pub fn accent() -> Color {
a... | 20.923077 | 62 | 0.487132 |
61c297e0d76db8f0a76e062e22faeaff0b240fb4 | 12,712 | // Copyright 2015-2017 Benjamin Fry <benjaminfry@me.com>
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://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... | 29.562791 | 126 | 0.578272 |
87d4153ee20e17d1caf3da50504015916dac31cf | 4,051 | #[doc = "Counter compare values\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify... | 72.339286 | 552 | 0.6902 |
61aeb99d0339ca3a51370b2a5e7d2754665b7870 | 4,182 | use std::f64::INFINITY;
use std::fmt;
use crate::errors::{Result, TaError};
use crate::{Low, Next, Period, Reset};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// Returns the lowest value in a given time frame.
///
/// # Parameters
///
/// * `period` - Size of the time frame (integer greater than 0... | 22.483871 | 79 | 0.512434 |
4a63a4886de4f7d2e23da53b3a1473bf22439a5f | 4,440 | use std::collections::HashMap;
use crate::net::message;
use crate::leader::tag::Tag;
use tokio::time::{sleep, Duration, Instant};
use tokio::sync::{oneshot, Mutex, mpsc};
use std::sync::Arc;
#[derive(Debug)]
pub enum HeartbeatOutput {
HeartbeatNotReceived(String),
}
pub struct HeartbeatMonitor {
following: Op... | 35.238095 | 108 | 0.513063 |
6116fea9d14310b05b97f76fca446c990812a493 | 1,233 | // Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unl... | 36.264706 | 94 | 0.673966 |
fb626a450f3e3945646668e7bb660ff58200d1df | 5,247 | use std::sync::MutexGuard;
use crate::{palette::ColorPalette, MEM};
pub fn reset(mutex_guard: Option<&mut MutexGuard<[u8; 0x8000]>>) {
let mut mutex;
let mg = match mutex_guard {
Some(mg) => mg,
None => {
mutex = MEM.lock().unwrap();
&mut mutex
}
};
res... | 22.32766 | 93 | 0.502763 |
718d63a58381f8533e0ed3e40aa87727f8b81655 | 50,332 | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::F3R2 {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce... | 25.771633 | 60 | 0.464456 |
3996841eebb61793b412825742c8b678744491d9 | 8,325 | use crate::utils::{
build_compact_block, build_compact_block_with_prefilled, clear_messages, wait_until,
};
use crate::{Net, Node, Spec, TestProtocol};
use ckb_chain_spec::ChainSpec;
use ckb_core::header::HeaderBuilder;
use ckb_network::PeerIndex;
use ckb_protocol::{get_root, RelayMessage, RelayPayload, SyncMessage... | 35.576923 | 106 | 0.597958 |
7a3a335ea6d9f8cf29c398f2210c2215a057284d | 20,234 | //! Fairings: callbacks at attach, launch, request, and response time.
//!
//! Fairings allow for structured interposition at various points in the
//! application lifetime. Fairings can be seen as a restricted form of
//! "middleware". A fairing is an arbitrary structure with methods representing
//! callbacks that Ro... | 41.633745 | 97 | 0.638826 |
50c2c458c4bde5e885b98b69b55f51f353af1e1c | 6,217 | #![doc = include_str!("../docs/response.md")]
use crate::body::{Bytes, Full};
use http::{header, HeaderValue};
mod redirect;
pub mod sse;
#[doc(no_inline)]
#[cfg(feature = "json")]
pub use crate::Json;
#[doc(no_inline)]
#[cfg(feature = "headers")]
pub use crate::TypedHeader;
#[doc(no_inline)]
pub use crate::Exten... | 28.004505 | 99 | 0.516165 |
4a32d405db20cc02b6fdcb6cffd7331b2ad4f07b | 6,878 | #![cfg(target_os = "macos")]
use std::os::raw::c_void;
use crate::{
dpi::LogicalSize,
event_loop::EventLoopWindowTarget,
monitor::MonitorHandle,
window::{Window, WindowBuilder},
};
/// Additional methods on `Window` that are specific to MacOS.
pub trait WindowExtMacOS {
/// Returns a pointer to t... | 34.737374 | 103 | 0.699186 |
ed56b968da7fda039f856e6c1badb0550055fd42 | 4,884 | use cast::{u64, u8};
use codemap::CodeMap;
use codemap_diagnostic::{ColorConfig, Diagnostic, Emitter, Level, SpanLabel, SpanStyle};
use serde::Deserialize;
use serde_taml::de::{from_taml_str, EncodeError};
use std::{borrow::Cow, io::stdout, iter};
use taml::diagnostics::{DiagnosticLabel, DiagnosticLabelPriority, Diagno... | 27.133333 | 88 | 0.608927 |
7aa626221aea5748b64982fec32c811974c9d532 | 130 | fn f() {
block_flow.base.stacking_relative_position_of_display_port = self.base.stacking_relative_position_of_display_port;
}
| 32.5 | 118 | 0.838462 |
186d9b2b665e4ffdce698d31507e367d6362d1f9 | 10,498 | use serde::Deserialize;
use crate::query::Query;
use crate::{Client, Result};
/// A struct representing a Subsonic user.
#[derive(Debug, Deserialize)]
pub struct User {
/// A user's name.
pub username: String,
/// A user's email address.
pub email: String,
/// A user may be limited to the bit rate ... | 35.110368 | 86 | 0.604972 |
e672a4b56d914820af0b5a5bf6e51f7c603c78f4 | 7,610 | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#![deny(warnings)]
#![deny(rust_2018_idioms)]
#![deny(clippy::all)]
use docblock_syntax::DocblockSource;
use graphql_syntax::Gra... | 33.086957 | 102 | 0.365177 |
14a6f09a1c69d7cd9601df05ac586314b311f2e6 | 3,031 | // Copyright (c) 2019 Stefan Lankes, RWTH Aachen University
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://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 distribu... | 22.619403 | 77 | 0.676015 |
8af75fdb3dca947950ddd5a4244f8c79fd433c71 | 1,555 | //! Ed25519: Schnorr signatures using the twisted Edwards form of Curve25519
//!
//! Described in RFC 8032: <https://tools.ietf.org/html/rfc8032>
//!
//! This module contains two convenience methods for signing and verifying
//! Ed25519 signatures which work with any signer or verifier.
//!
//! # Example (with ed25519-... | 30.490196 | 80 | 0.684244 |
edb170551f2031d39519a2fbcc33d16740a75cfd | 1,560 | use crate::source::SourcePoll;
use core::pin::Pin;
use core::task::Context;
use super::Source;
/// An interface for calling poll_events on trait objects when state is not known.
///
/// Simply passes through poll_events to the underlying `Source`
pub trait StatelessSource {
/// The type used for timestamping even... | 36.27907 | 378 | 0.671795 |
e226d67844edccb7f3525f671acef8bc1d0c706d | 393 | fn main()
{
let v1 = vec![ 1, 2, 3 ];
println!( "all elements of {:?} are greater than zero : {}", v1, v1.iter().all( | &e | e > 0 ) );
// : all elements of [1, 2, 3] are greater than zero : true
let v2 = [ 1, 2, -3 ];
println!( "all elements of {:?} are greater than zero : {}", v2, v2.iter().all( | &e | e > ... | 39.3 | 99 | 0.524173 |
ccdc7b833e714401c32f84fd8b7d7a4f5aa06268 | 1,110 | // 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 ... | 29.210526 | 74 | 0.654054 |
647593609979c88259380e5fa08bf340aa8b919c | 6,907 | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | 32.125581 | 96 | 0.62357 |
50af05310079ddda961b616c7715635ddf220d73 | 7,744 | // Copyright (c) 2018 Colin Finck, RWTH Aachen University
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://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 distribute... | 31.737705 | 112 | 0.701188 |
5bf797b3d7c24381b135534240c9f2d8ea7671d5 | 235 | #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Card {
pub id: i32,
pub text: String,
pub count: u32,
pub uses: i32,
pub rounds: i32,
pub personal: bool,
pub remote: bool,
pub unique: bool,
}
| 19.583333 | 47 | 0.612766 |
c19a3f8bdae8df2384b2e0c65542b23c40b5747b | 1,495 | // Copyright 2018 PingCAP, 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 i... | 29.9 | 70 | 0.664214 |
d5f9c5041ec5d409d1a718eecf1d47f4d94d900d | 8,663 | mod model;
mod uploader;
use async_trait::async_trait;
use http::Uri;
use model::endpoint::Endpoint;
use opentelemetry::sdk::resource::ResourceDetector;
use opentelemetry::sdk::resource::SdkProvidedResourceDetector;
use opentelemetry::sdk::trace::Config;
use opentelemetry::sdk::Resource;
use opentelemetry::{
globa... | 34.513944 | 129 | 0.599677 |
b9f0d7ed67628862e65222ab0354395afbeae8da | 4,624 | #[doc = "Register `MUTEX[%s]` reader"]
pub struct R(crate::R<MUTEX_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<MUTEX_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl core::convert::From<crate::R<MUTEX_SPEC>> for R {
fn from(reader: crate::R<MUTEX_... | 29.265823 | 424 | 0.579369 |
2285cbfd26f73a8ae465ac59a70c6cd77f671009 | 4,201 | use crate::leaderArrange::LeaderSchedule;
use crate::stakingUtils;
use morgan_runtime::bank::Bank;
use morgan_interface::pubkey::Pubkey;
use morgan_interface::timing::NUM_CONSECUTIVE_LEADER_SLOTS;
/// Return the leader schedule for the given epoch.
pub fn leader_schedule(epoch_height: u64, bank: &Bank) -> Option<Leade... | 33.608 | 97 | 0.633897 |
181a1a61552f5b7463faa496d7adc76083e29d4c | 71,636 | use std::borrow::Cow;
use std::cmp::min;
use itertools::Itertools;
use syntax::parse::token::{DelimToken, LitKind};
use syntax::source_map::{BytePos, Span};
use syntax::{ast, ptr};
use crate::chains::rewrite_chain;
use crate::closures;
use crate::comment::{
combine_strs_with_missing_comments, comment_style, conta... | 34.49013 | 100 | 0.536881 |
61976b232376a40bb060fd9f6130644e7800faec | 10,481 | use crate::{
errors::{HealthchecksApiError, HealthchecksConfigError},
model::{Channel, Check, Flip, NewCheck, Ping, UpdatedCheck},
util::default_user_agent,
};
use std::result::Result;
use ureq::{delete, get, post, Error, Request};
const HEALTHCHECK_API_URL: &str = "https://healthchecks.io/api/v1/";
/// T... | 44.411017 | 99 | 0.585154 |
0efb47197ad3726900894d2c693c946b2992b319 | 3,776 | use serde::de::{self, Deserialize, Deserializer, Error as DeError};
use serde::ser::{Serialize, Serializer};
use ::overlay::{Color as OverlayColor, Outline as OverlayOutline};
use ::utils::RGB;
impl Serialize for Color {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer
... | 25.342282 | 114 | 0.458157 |
e8a12247cbffaeafac328712981dee90af3741b6 | 1,657 | // Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
// refer to the Cargo.toml file at the top-level directory of this distribution.
//
// 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 ... | 40.414634 | 102 | 0.671092 |
f4ee1ef77a018e19bb7b1b54c79caa59a6442400 | 5,060 | use super::{Map, TileType};
use rltk::{FontCharType, RGB};
pub fn tile_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) {
let (glyph, mut fg, mut bg) = match map.depth {
2 => get_forest_glyph(idx, map),
_ => get_tile_glyph_default(idx, map),
};
if map.visible_tiles[idx] {
i... | 29.418605 | 78 | 0.461858 |
38ff5a82bcfe8d68ef40c9a497e9112d1d3c09cb | 2,009 | use chromiumoxide_cdp::cdp::browser_protocol::emulation::{
ScreenOrientation, ScreenOrientationType, SetDeviceMetricsOverrideParams,
SetTouchEmulationEnabledParams,
};
use chromiumoxide_types::Method;
use crate::cmd::CommandChain;
use crate::handler::viewport::Viewport;
use std::time::Duration;
#[derive(Debug... | 30.439394 | 79 | 0.60229 |
7986191f858067daf4394bee09e5b7a0eb1f3438 | 567 | use reqwest::Certificate;
use crate::core::Result;
use std::io::Read;
use std::{fs::File, path::Path};
pub fn load<P: AsRef<Path>>(path: P) -> Result<Certificate> {
let mut buf = Vec::new();
File::open(&path)?.read_to_end(&mut buf)?;
let cert = certificate(path, &buf)?;
Ok(cert)
}
fn certificate<P: A... | 25.772727 | 82 | 0.599647 |
4878005268dc77d5325496dc3b5f2f62847c238a | 13,780 | use crate::numbers::*;
#[cfg(all(feature = "use_simd"))]
use packed_simd::*;
use std;
use std::mem;
use std::ops::*;
mod simd_partition;
pub use self::simd_partition::{EdgeIteratorMut, IndexedEdgeIteratorMut, SimdPartition};
/// SIMD methods which have `f32` or `f64` specific implementation.
pub trait Simd<T>: Sized
w... | 34.886076 | 111 | 0.58643 |
9b9e25326f9663b11e84984b0acb71e59ffc1cfa | 12,440 | use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::higher;
use clippy_utils::ty::is_type_diagnostic_item;
use clippy_utils::{path_to_local, usage::is_potentially_mutated};
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::intravisit::{walk_expr, walk_fn, FnKind, Visitor};
use rus... | 37.69697 | 107 | 0.511013 |
e6712bc78f450001db0288cbaad2a9f0bae87398 | 52,491 | use std::mem;
use std::slice;
use std::i32;
use std::collections::{BTreeMap, HashMap};
use std::marker::PhantomData;
use std::hash::Hash;
use webcore::ffi;
use webcore::callfn::{CallOnce, CallMut};
use webcore::newtype::Newtype;
use webcore::try_from::{TryFrom, TryInto};
use webcore::number::Number;
use webcore::type_... | 28.465835 | 153 | 0.513174 |
501147ed4593ba6748c724eba77a70016a42a8ff | 41,829 | //! HTML formatting module
//!
//! This module contains a large number of `fmt::Display` implementations for
//! various types in `rustdoc::clean`. These implementations all currently
//! assume that HTML output is desired, although it may be possible to redesign
//! them in the future to instead emit any format desire... | 34.626656 | 99 | 0.406417 |
29eb4ea451fea76fc37fc9045a0f72fa9f1493e3 | 1,851 | // Copyright 2018 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use std::ops::Deref;
use crate::bindings::libusb_endpoint_descriptor;
use crate::types::{EndpointDirection, EndpointType};
/// EndpointDescriptor wra... | 31.913793 | 85 | 0.681253 |
09a70c3a686078c2c6b10aa208abe6fa1fc3d50d | 343 | pub trait ResultFn {
type Result;
fn result(self) -> Self::Result;
}
impl ResultFn for () {
type Result = ();
fn result(self) {}
}
pub struct Id<T>(T);
impl<T> ResultFn for Id<T> {
type Result = T;
fn result(self) -> T {
self.0
}
}
impl<T> Id<T> {
pub fn new(v: T) -> Self {
... | 13.72 | 36 | 0.504373 |
3883d86520fee7334b17a63cc7e732ea30198d34 | 45,561 | //! An "interner" is a data structure that associates values with usize tags and
//! allows bidirectional lookup; i.e., given a value, one can easily find the
//! type, and vice versa.
use rustc_arena::DroplessArena;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::{HashStable, Stabl... | 26.959172 | 100 | 0.571827 |
69adb15f039374906a537fc95e6562979b191de3 | 17,202 | extern crate serde;
extern crate rltk;
use rltk::{Console, GameState, Rltk, Point};
extern crate specs;
use specs::prelude::*;
use specs::saveload::{SimpleMarker, SimpleMarkerAllocator};
#[macro_use]
extern crate specs_derive;
mod components;
pub use components::*;
mod map;
pub use map::*;
mod player;
use player::*;
mo... | 38.397321 | 156 | 0.551157 |
7aeb0fc77649b4f336b0e6066c75306414596dcf | 3,877 | //! msq is a rust library implementation of the legacy [Master Server Query Protocol](https://developer.valvesoftware.com/wiki/Master_Server_Query_Protocol).
//!
//! # Usage
//! Add this to your `Cargo.toml`:
//! ```toml
//! [dependencies]
//! msq = "0.2"
//! ```
//! If you want to get straight from the latest master b... | 33.136752 | 157 | 0.570028 |
91a39f7b9b4ef024b92c27d9510f14edafead135 | 3,125 | // This defines a base target-configuration for native UEFI systems. The UEFI specification has
// quite detailed sections on the ABI of all the supported target architectures. In almost all
// cases it simply follows what Microsoft Windows does. Hence, whenever in doubt, see the MSDN
// documentation.
// UEFI uses COF... | 51.229508 | 97 | 0.69504 |
1ea95665f0f9567975de4baf84be3a25b890526b | 1,368 | // Copyright 2015-2021 Swim 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 ... | 36.972973 | 96 | 0.695906 |
872eb25df95663296c4b46dcb2ea9e6c8a62a9d4 | 14,289 | // 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 super::traits::{FieldElement, StarkField};
use crate::errors::{ElementDecodingError, SerializationError};
use core::{
convert::{Tr... | 29.280738 | 99 | 0.545455 |
ff11965c394f07d8febd808cb7dd1ca6aa5c5e37 | 4,071 | //! Methods for triangular matrices
use ndarray::*;
use num_traits::Zero;
use super::convert::*;
use super::error::*;
use super::lapack_traits::*;
use super::layout::*;
use super::types::*;
pub use super::lapack_traits::Diag;
/// solve a triangular system with upper triangular matrix
pub trait SolveTriangular<A, S,... | 26.264516 | 118 | 0.564972 |
11572a40602155fb1a446ddf471e65490213671c | 6,674 | #![recursion_limit = "1024"]
#[macro_use]
extern crate cpp;
use std::{
os::raw::c_char,
ffi::CStr,
io,
path::Path,
};
#[cfg(windows)]
mod os
{
use std::ffi::OsStr;
use std::os::windows::ffi::OsStrExt;
pub(crate) type NodSystemChar = u16;
pub(crate) fn os_str_to_sys_char(s: &OsStr) ->... | 24.810409 | 99 | 0.489661 |
dddaf43d653107d7f22da34f35cb88bd26a57550 | 4,377 | use std::result;
use super::BOARD_WIDTH;
pub type Result<T> = result::Result<T, String>;
const MOVEMENT_SPEED: f64 = 1.0;
pub static TETROMINOS: [Tetromino; 7] = [
Tetromino {
name: Shape::I,
blocks: [[0, 1, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0]],
x_offset: (BOARD_WIDTH as f64 / 2.0) - 2.0,
... | 23.532258 | 82 | 0.488005 |
64d6a01d4f5572e42a33a689f71291650efa7303 | 4,036 | #![allow(missing_docs)]
/// Derived from https://github.com/project-serum/anchor/blob/9224e0fa99093943a6190e396bccbc3387e5b230/examples/pyth/programs/pyth/src/pc.rs
use bytemuck::{
cast_slice, cast_slice_mut, from_bytes, from_bytes_mut, try_cast_slice, try_cast_slice_mut,
Pod, PodCastError, Zeroable,
};
u... | 29.246377 | 141 | 0.600842 |
29736f2765e9516500d0db8e08fd780b71277b62 | 431,440 | // automatically generated by the FlatBuffers compiler, do not modify
use std::cmp::Ordering;
use std::mem;
extern crate flatbuffers;
use self::flatbuffers::EndianScalar;
#[allow(unused_imports, dead_code)]
pub mod fbsemantic {
use std::cmp::Ordering;
use std::mem;
extern crate flatbuffers;
use sel... | 33.864992 | 100 | 0.514894 |
db50750211c5e34d89ad6ada28d8edb1dc36e00c | 4,381 | use std::collections::hash_map::{Entry, HashMap};
use crate::{
ast::InputValue,
parser::{SourcePosition, Spanning},
validation::{ValidatorContext, Visitor},
value::ScalarValue,
};
pub struct UniqueInputFieldNames<'a> {
known_name_stack: Vec<HashMap<&'a str, SourcePosition>>,
}
pub fn factory<'a>(... | 25.47093 | 96 | 0.453093 |
e4427e590f8f7f59e527cbcf51cc3a3036247b7f | 29,362 | // Copyright Materialize, Inc. and contributors. All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//! This module provides a TCP-based boundary.
use serde::{Deserialize, Serialize};
use timely::dataflow::operators::capture::EventCore;
use time... | 38.083009 | 128 | 0.537395 |
1e2a3c8df3d5d40d8d3b8bc8193b2473b234680e | 23,479 | #[cfg(test)]
mod test {
#[cfg(feature = "dim2")]
use na;
#[cfg(feature = "dim2")]
use na::{Vector1, Vector2, Isometry2};
#[cfg(feature = "dim2")]
use ncollide::shape::Cuboid;
#[cfg(feature = "dim2")]
use object::{ActivationState, RigidBody};
#[cfg(feature = "dim2")]
use world::Wo... | 47.432323 | 152 | 0.583159 |
22a06b9f605dbdc66f5b70bdfb2fd84b5b079141 | 7,867 | // Copyright 2012-2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | 32.508264 | 100 | 0.526376 |
693293facd4d51aa14c8a219764632bae589fd56 | 1,272 | // IO error is used here just as an example of an already existing
// Error
use std::io::{Error, ErrorKind};
// Rust technically doesn't have exception, but different
// types of error handling. Here are two examples of results.
pub fn valid_function() -> Result<usize, Error> {
Ok(100)
}
pub fn errored_function(... | 24.461538 | 71 | 0.587264 |
1deabc3f3fdbe6046fa81a0ddda5d4f4a64f2690 | 3,411 | //bring code from other libraries in scope of this file
extern crate clap;
use ansi_term::Colour::{Green, Red};
use ansi_term::Style;
use clap::{App, Arg};
use date_diff_lib;
///The starting point of the application
fn main() {
//this function is different for Windows and for Linux.
//Look at the code of this ... | 35.53125 | 93 | 0.640281 |
1e746e8e4c6d336f09e13cefae886166a65af1d8 | 725 | #![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
use std::io;
use std::env;
use std::path::{Path, PathBuf};
use rocket::response::NamedFile;
#[get("/")]
fn index() -> io::Result<NamedFile> {
let page_directory_path = get_directory_path();
NamedFile::open(Path::new(&page_direc... | 25 | 71 | 0.667586 |
143950e1e7f3d39cb0908650d0188d04a2db4e93 | 1,750 | extern crate run_length_encoding as rle;
// encoding tests
#[test]
fn test_encode_empty_string() {
assert_eq!("", rle::encode(""));
}
#[test]
#[ignore]
fn test_encode_single_characters() {
assert_eq!("XYZ", rle::encode("XYZ"));
}
#[test]
#[ignore]
fn test_encode_string_with_no_single_characters() {
asse... | 20.114943 | 78 | 0.690857 |
2915e09e1fc3c2314eed5062f79c999908c8bf20 | 2,779 | // Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unl... | 32.694118 | 97 | 0.623246 |
144bdab0390280700ec4d39b0fd01d432d1e6893 | 4,134 | use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::nu;
use nu_test_support::{pipeline, playground::Playground};
#[test]
fn takes_rows_of_nu_value_strings_and_pipes_it_to_stdin_of_external() {
Playground::setup("internal_to_external_pipe_test_1", |dirs, sandbox| {
sandbox.with_f... | 24.903614 | 99 | 0.489115 |
0992e3a85ae94964023d9e2db4037b77640ee64b | 250 | #![feature(nll)]
fn main() {
let i = &3;
let f = |x: &i32| -> &i32 { x };
//~^ ERROR lifetime may not live long enough
let j = f(i);
let g = |x: &i32| { x };
//~^ ERROR lifetime may not live long enough
let k = g(i);
}
| 17.857143 | 48 | 0.48 |
5b6215d7c42caf499f32f546d02573622effe5d7 | 11,114 | #[doc = "Register `GMAC_TSR` reader"]
pub struct R(crate::R<GMAC_TSR_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<GMAC_TSR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<GMAC_TSR_SPEC>> for R {
#[inline(always)]
fn from(reader: ... | 28.065657 | 413 | 0.554706 |
1a42f91702d7533172b9f08fc1e74a88a00ff685 | 114,532 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
#[allow(clippy::unnecessary_wraps)]
pub fn parse_create_cluster_error(
response: &http::Response<bytes::Bytes>,
) -> std::result::Result<crate::output::CreateClusterOutput, crate::error::CreateClusterError> {
let generic = crate::j... | 45.739617 | 230 | 0.556866 |
e22bc0bdc4892c5e3397f2de4838de31e9b102b3 | 6,317 | //! ABI definitions.
use crate::ir::{ArgumentExtension, StackSlot};
use crate::machinst::*;
use crate::settings;
use regalloc::{Reg, Set, SpillSlot, Writable};
/// Trait implemented by an object that tracks ABI-related state (e.g., stack
/// layout) and can generate code while emitting the *body* of a function.
pub ... | 39.48125 | 97 | 0.660598 |
89497cde96787101c923a6d348d872f0a2f184d2 | 21,358 | //! This module contains the implementation of a virtual element node `VTag`.
use super::{Attributes, Classes, Listener, Listeners, Patch, Reform, VDiff, VNode};
use crate::html::{Component, Scope};
use log::warn;
use std::borrow::Cow;
use std::cmp::PartialEq;
use std::collections::HashSet;
use std::fmt;
use stdweb::u... | 36.951557 | 105 | 0.517839 |
1ad9208e93f6cb0394bf4295684cda7d4aded3b6 | 3,621 | use wasm_bindgen_test::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen(module = "tests/wasm/imports.js")]
extern {
fn test_simple();
fn simple_foo(s: &str);
fn simple_another(a: u32) -> i32;
fn simple_take_and_return_bool(a: bool) -> bool;
fn simple_return_object() -> JsValue;
#[allow(dead_cod... | 20.22905 | 61 | 0.684341 |
675ca4cb73a5e99282cd34c90a070fc00a69515d | 2,786 | #[doc = "Reader of register TER"]
pub type R = crate::R<u32, super::TER>;
#[doc = "Writer for register TER"]
pub type W = crate::W<u32, super::TER>;
#[doc = "Register TER `reset()`'s with value 0x80"]
impl crate::ResetValue for super::TER {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {... | 54.627451 | 775 | 0.666906 |
f8a9c9b119a66b0f253fd4100d347dc1a8d1c24f | 5,983 | use crate::extensions::NodeExt as _;
use crate::hud;
use crate::mob;
use crate::player;
use gdnative::api::*;
use gdnative::*;
use rand::*;
use std::f64::consts::PI;
#[derive(Debug, Clone, PartialEq)]
pub enum ManageErrs {
CouldNotMakeInstance,
RootClassNotRigidBody2D(String),
}
#[derive(NativeClass)]
#[inher... | 30.52551 | 99 | 0.557747 |
5bb6caee621fe7d00fad5d2926c249cbfce63c6c | 753 | use crate::{
format_elements, group_elements, space_token, FormatElement, Formatter, ToFormatElement,
};
use rslint_parser::ast::IfStmt;
impl ToFormatElement for IfStmt {
fn to_format_element(&self, formatter: &Formatter) -> Option<FormatElement> {
let mut result = format_elements![
group_elements(format_elemen... | 24.290323 | 89 | 0.690571 |
e64e8a1988d7e1aba0567af0b8f441b9ea1d9b41 | 438 | pub mod app;
mod cmd;
type Action = fn() -> anyhow::Result<()>;
pub struct Argument {
name: String,
usage: String,
value: Value,
hidden: bool,
required: bool,
aliases: Vec<String>,
env_vars: Vec<String>,
description: String,
}
pub enum Value{
Bool(bool),
I32(i32),
U32(u32)... | 15.103448 | 41 | 0.586758 |
ab5d410e7965dfde121e9c62bb4740f28d635a99 | 6,050 | // Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::fidl_processor::{process_stream, RequestContext},
crate::switchboard::base::*,
crate::switchboard::hanging_get_handler::Sender,
... | 33.798883 | 99 | 0.564628 |
080fc56e77ea2d7a059682260b64ef6bb0b698b4 | 279 | extern crate protoc_grpcio;
fn main() {
let proto_root = "src/protos";
println!("cargo:rerun-if-changed={}", proto_root);
protoc_grpcio::compile_grpc_protos(&["api.proto"], &[proto_root], &proto_root, None)
.expect("Failed to compile gRPC definitions!");
}
| 27.9 | 88 | 0.673835 |
229962cbcca2846fa402b3166fd7903b891ec1c4 | 16,161 | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::account_address::AccountAddress;
use crate::transaction::{RawUserTransaction, SignedUserTransaction};
use anyhow::{ensure, Error, Result};
#[cfg(any(test, feature = "fuzzing"))]
use proptest_derive::Arbitrary;
use rand::{rngs... | 32.582661 | 135 | 0.635171 |
0ae971542a04b897774d0a025eaf268c5df2b2b5 | 15,887 | // Copyright (c) 2017 The vulkano developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>,
// at your option. All files in the project carrying such
// notice may not be ... | 27.018707 | 97 | 0.664883 |
167b303f073212fa16b912c79f23ed354a6210e6 | 5,925 | use std::io;
use monoio::buf::IoBufMut;
use monoio::io::AsyncWriteRent;
use monoio::BufResult;
use monoio::{io::AsyncReadRent, net::TcpStream};
use crate::box_future::MaybeArmedBoxFuture;
use crate::buf::Buf;
pub struct TcpStreamCompat {
stream: TcpStream,
read_buf: Option<Buf>,
write_buf: Option<Buf>,
... | 35.479042 | 99 | 0.552911 |
398572d12fc87320cd4bf79e7fe6d180019c7524 | 3,167 | use std::mem;
/// Represents a value that is not checked at first, and upon being checked it might be available
/// or unavailable.
pub enum MaybeUnavailable<T> {
// I'm not that great at naming.
NotChecked,
Unavailable,
Available(T),
}
impl<T> MaybeUnavailable<T> {
/// Resets this value to the no... | 32.649485 | 97 | 0.590148 |
dda79d13acc4e77b237c0400f2918ea273c43fa0 | 4,475 | // Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{
local_client::LocalClient,
persistent_storage::PersistentStorage,
remote_service::RemoteService,
serializer::{SerializerClient, SerializerService},
spawned_process::SpawnedProcess,
thread::ThreadSer... | 36.983471 | 98 | 0.651397 |
38fcabb5cc170fc360b8de518de23a80b10b5dba | 158 | #![feature(existential_type)]
existential type Foo: Fn() -> Foo;
//~^ ERROR: could not find defining uses
fn crash(x: Foo) -> Foo {
x
}
fn main() {
}
| 12.153846 | 40 | 0.607595 |
eb059f09343fceb02dc329668198ba19ee7ec896 | 2,140 | use bitvec::prelude::*;
struct ParseResult {
len: usize,
version_sum: u64,
result: u64,
}
fn parse_packet(packet: &BitSlice<Msb0, u8>) -> ParseResult {
let version: u8 = packet[0..3].load_be();
let type_id: u8 = packet[3..6].load_be();
if type_id == 4 {
let mut len = 6;
let mu... | 26.097561 | 70 | 0.488785 |
913442572c593b7ad388322f9acc1c2639288a26 | 9,563 | // Copyright 2020 The Matrix.org Foundation C.I.C.
//
// 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... | 31.048701 | 92 | 0.60985 |
bb5149fc08a8df37de9c05819df50c5069325359 | 1,478 | use std::num::NonZeroU32;
use std::sync::atomic::{AtomicU32, Ordering};
use crate::context::ModuleId;
/// Identifier for a local variable within a module
///
/// This is not globally unique; it must be combined with a `ModuleId`
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, PartialOrd, Ord)]
pub struct LocalId(No... | 26.392857 | 96 | 0.655616 |
e4de74168443d19e5000e920a893b21d70949d55 | 12,352 | // This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT
use crate::Accessible;
use crate::AccessibleRole;
use crate::Adjustment;
use crate::Align;
use crate::Buildable;
use crate::ConstraintTarget;
use crate::LayoutManager;
use crate:... | 30.957393 | 133 | 0.589702 |
e5b6dcfe2099219bad64667f98ba9a25086559c3 | 1,338 | #![allow(unused_variables)]
#![allow(dead_code)]
fn main() {
enum Opt<T> {
Some(T),
None,
}
let x: Opt<i32> = Opt::Some(3);
let y: Opt<f64> = Opt::Some(5.0);
enum Res<T, E> {
Ok(T),
Err(E),
}
let x: Res<i32, &'static str> = Res::Ok(3);
let y: Res<i32, ... | 20.90625 | 53 | 0.414051 |
d9e99103fa419ff7fd1f880e4836e7d62548add9 | 4,731 | use arrayvec::ArrayVec;
use super::{ascii, DataEncodingError, EncodingContext};
pub(crate) const UNLATCH: u8 = 0b011111;
#[cfg(test)]
use alloc::vec;
#[inline]
pub(crate) fn is_encodable(ch: u8) -> bool {
matches!(ch, 32..=94)
}
/// Encode 1 to 4 characters using EDIFACT and write it to the context.
fn write4<... | 30.133758 | 88 | 0.534771 |
71864b3e65b649e7f0db8e92afde00860af494f2 | 17,783 | use super::{Interest, Ready, ReadyEvent, Tick};
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Mutex;
use crate::util::bit;
use crate::util::slab::Entry;
use std::sync::atomic::Ordering::{AcqRel, Acquire, Release};
use std::task::{Context, Poll, Waker};
use super::Direction;
cfg_io_readiness! {
... | 32.629358 | 99 | 0.500534 |
9b83e258f75aca57f827b1b8c54ecf76f5682b5e | 5,475 | // Copyright 2020 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 in w... | 35.784314 | 93 | 0.690046 |
f49c2647077462ab4a886f26fd85c596ec7f8ad8 | 742 | use js_sys::Math::random;
/// Container for cross-platform Random methods
#[derive(Debug)]
pub struct Random {}
impl Random {
/// returns a random f32 value between an upper & lower bound
pub fn gen_range_f32(lower: f32, upper: f32) -> f32 {
let rand_range: f32 = random() as f32 * (upper - lower);
... | 29.68 | 75 | 0.623989 |
db72450347970485b80b58c3ddc265afd36b2e62 | 13,145 | use libc::{c_int, c_void, size_t};
use libproc::libproc::bsd_info::BSDInfo;
use libproc::libproc::file_info::{pidfdinfo, ListFDs, ProcFDType};
use libproc::libproc::net_info::{InSockInfo, SocketFDInfo, SocketInfoKind, TcpSockInfo};
use libproc::libproc::pid_rusage::{pidrusage, RUsageInfoV2};
use libproc::libproc::proc_... | 32.376847 | 100 | 0.483454 |
09fc25fd01c0e85a21eff204df986729923cd851 | 5,664 | //! Naming is confusing, but RawMap -> InitialMap -> Map. InitialMap is separate pretty much just
//! for the step of producing <https://a-b-street.github.io/docs/map/importing/geometry.html>.
use std::collections::{BTreeMap, BTreeSet};
use anyhow::Result;
use abstutil::{Tags, Timer};
use geom::{Bounds, Circle, Dist... | 32.551724 | 99 | 0.519421 |
1d25bed917f6d17f82514a7f330efa4d141a80f2 | 3,743 | //! **ls-tiny** is a less functional `ls` command
//! it is somewhat richer than when no argument to the ls command is specified. (Because it's a little colored.)
#[macro_use]
extern crate clap;
use clap::{Arg, App};
use colored::Colorize;
use std::path::{Path, PathBuf};
/// The Config structure has four fields
/// *... | 32.833333 | 112 | 0.565589 |
909fca2ab586f2e983894772c5cf87231422616d | 3,065 | #![allow(non_snake_case)]
use syntax::{register_diagnostics, register_long_diagnostics};
register_long_diagnostics! {
E0454: r##"
A link name was given with an empty name. Erroneous code example:
```ignore (cannot-test-this-because-rustdoc-stops-compile-fail-before-codegen)
#[link(name = "")] extern {}
// error: `#[... | 29.471154 | 86 | 0.703752 |
9021b485e7711ec2bc0dc4b36c040eee4e3c1cd8 | 803 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn serialize_structure_create_workspace_input(
object: &mut smithy_json::serialize::JsonObjectWriter,
input: &crate::input::CreateWorkspaceInput,
) {
if let Some(var_1) = &input.alias {
object.key("alias").string(va... | 32.12 | 80 | 0.684932 |
f785cd0857f072c3e56fea57bf79e02e1d32ae7b | 92 | fn main() {
let i = 0;
let mut i = 1;
i += 1;
i += 1;
print!("{}", i);
} | 13.142857 | 20 | 0.315217 |
87859a54a13bb57f83bfd4959940d42805ffe458 | 21,025 | #![cfg_attr(feature = "clippy", allow(while_let_on_iterator))]
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::str::FromStr;
use client::{Cluster, Metadata};
use errors::{Error, Result};
use network::TopicPartition;
/// Strategy for assigning partitions to consumer streams.
#[derive(Clone, D... | 34.637562 | 118 | 0.557194 |
90407282a5ea4836725d7f011a6ca3aaa2404c3c | 5,953 | // This file is auto-generated! Any changes to this file will be lost!
mod tests {
use woothee::parser::Parser;
#[test]
fn test_mobilephone_misc() {
let parser = Parser::new();
match parser.parse(r#"Mozilla/5.0 (jig browser core; SH03B)"#) {
None => panic!(r#"invalid parse. "M... | 51.318966 | 206 | 0.543088 |
f81eac64275f906d83fdd3c36dce421d16358267 | 44,836 | use std::panic::Location;
use std::fmt::Debug;
use std::pin::Pin;
use std::marker::Unpin;
use std::future::Future;
use std::task::{Context, Poll};
use log::trace;
use futures_core::stream::Stream;
use futures_util::stream;
use futures_util::stream::StreamExt;
use pin_project::pin_project;
use crate::intern... | 30.335589 | 143 | 0.500067 |
2698f964cc69dfd128fa4aa719b7b0bf9d1f6449 | 3,268 | use crate::prelude::*;
use nu_engine::WholeStreamCommand;
use nu_errors::ShellError;
use nu_protocol::{Primitive, ReturnSuccess, Signature, TaggedDictBuilder, UntaggedValue, Value};
pub struct FromToml;
#[async_trait]
impl WholeStreamCommand for FromToml {
fn name(&self) -> &str {
"from toml"
}
f... | 31.12381 | 100 | 0.566095 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.