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 |
|---|---|---|---|---|---|
d9c875e60bc0929aa7918f17f910ad349ccad131 | 27,256 | // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use crate::error::AnyError;
use crate::runtime::JsRuntimeState;
use crate::JsRuntime;
use crate::Op;
use crate::OpId;
use crate::OpTable;
use crate::ZeroCopyBuf;
use futures::future::FutureExt;
use rusty_v8 as v8;
use std::cell::Cell;
use std::... | 31.7669 | 105 | 0.666716 |
6422ff97d554c049e327a18e6f72305e77db5709 | 9,305 | use proc_macro2::{Ident, Span, TokenStream};
use shared::{map_type_params, split_for_impl};
use syn::{self, Data, DeriveInput, Fields, GenericParam, Generics};
use attr::{Container, CrateName};
pub fn derive(input: TokenStream) -> TokenStream {
let derive_input = syn::parse2(input).expect("Input is checked by rus... | 38.292181 | 119 | 0.41784 |
dd5d0109613753fb5244ab38bffc32aba8ce98bf | 14,703 | // This file is part of Deskchains.
// Copyright (C) 2020-2021 Deskchains Foundation.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program 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 So... | 33.264706 | 292 | 0.686595 |
fb7e500d3932a1b7ce8a8c09b02eda8923bbdbd7 | 6,426 | use crate::parser;
use crate::test_util::compare;
use super::expand_precedence;
use super::resolve::resolve;
#[test]
fn multilevel() {
let grammar = parser::parse_grammar(
r#"
grammar;
Expr: u32 = {
#[precedence(level="1")]
<left:Expr> "*" <right:Expr> => 0,
#[precedence(level="1"... | 21 | 94 | 0.455649 |
f9a523641e41e1dbef4377388c1fa82fc5aab0cd | 606 | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | 33.666667 | 69 | 0.681518 |
dd036447ed9442401b4fe4ba36690cca3d698750 | 847 | pub use self::client::Client;
pub use self::error::Error;
pub use self::publisher::{Publisher, PublisherStream};
pub use self::service::Service;
pub use self::subscriber::Subscriber;
use rosmsg::RosMsg;
use std::sync::atomic::AtomicUsize;
use std::sync::Arc;
use Clock;
mod client;
pub mod error;
mod header;
mod publi... | 21.717949 | 77 | 0.687131 |
e5d0cde69c9be2452bc1271fdcecac1440711c49 | 6,458 | //! Collection of composition types.
pub mod basic_f32;
pub mod basic_premultiplied_f32;
#[cfg(feature = "image-crate")]
pub mod image_rgb_rgba;
/// Compositor attributes
pub trait CompositorAttr {
/// If true, the compositor requires updating destinations even alpha is zero.
fn keep_dst_on_transparent_src(&s... | 33.811518 | 102 | 0.682874 |
4847073ebb9247079d4779f8b755706cd924d8d6 | 1,482 | #[doc = r" Value read from the register"]
pub struct R {
bits: u8,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u8,
}
impl super::UCA0IRTCTL {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w ... | 22.8 | 58 | 0.495951 |
bb1830a147e43ec196affc82aba84d01ed57941c | 11,102 | // 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 ... | 40.224638 | 80 | 0.545307 |
d7ad55c00700dbf6748e49f1f728dafdf46823cc | 41,629 | //! Instruction types
use crate::{
error::LendingError,
state::{ReserveConfig, ReserveFees},
};
use solana_program::{
instruction::{AccountMeta, Instruction},
msg,
program_error::ProgramError,
pubkey::{Pubkey, PUBKEY_BYTES},
sysvar,
};
use std::{convert::TryInto, mem::size_of};
/// Instruc... | 40.377304 | 129 | 0.614908 |
8fe8cf7084247dc81b2d69f9267069321d07c1e5 | 3,146 | use crate::clients::PathClient;
use crate::request_options::*;
use azure_core::prelude::*;
use azure_core::{AppendToUrlQuery, Response as HttpResponse};
use azure_storage::core::headers::CommonStorageResponseHeaders;
use std::convert::TryInto;
/// A future of a delete file response
type PutPath = futures::future::BoxF... | 32.102041 | 90 | 0.636999 |
4bf29aa3d9634ae26fe44370777deb0fee86825d | 694 | /* --- BEGIN Variable Definitions ---
Owner s; Owner mut x; Owner y; Owner some_string;
Function String::from();
Function takes_ownership();
Function println!()
--- END Variable Definitions --- */
fn main() {
let s = String::from("hello"); // !{ Move(String::from()->s) }
takes_ownership(s); // !{ Move(s->takes... | 40.823529 | 87 | 0.610951 |
0335d6fa6ca476ce3669538d0e0f4d0a04ec46d3 | 20,988 | // 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::Align;
use crate::Buildable;
use crate::ConstraintTarget;
use crate::Editable;
use crate::LayoutManager;
use crate::O... | 32.190184 | 167 | 0.567419 |
e998a0845d45715e6a1b7e5c9e24a8d908ab41df | 2,843 | #[macro_use]
extern crate nom;
use nom::{IResult,digit};
// Parser definition
use std::str;
use std::str::FromStr;
use self::Operator::*;
enum Operator {
Slash,
Star,
}
impl Operator {
fn to_str(&self) -> &'static str {
match *self {
Slash => "/",
Star => "*",
}... | 26.082569 | 124 | 0.520929 |
0a0943ff2d11f1c6a96a1adda6ddcacdc1d25618 | 1,108 | // structs1.rs
// Address all the TODOs to make the tests pass!
struct ColorClassicStruct {
// TODO: Something goes here
name : String,
hex : String
}
struct ColorTupleStruct(String, String);
#[derive(Debug)]
struct UnitStruct;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn classic_c_str... | 23.574468 | 86 | 0.572202 |
87517a13614e09c546c46c44ae8a4fa0912c84a0 | 10,279 | // Copyright 2019-2020 Twitter, Inc.
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
use std::sync::{Arc, Mutex};
use std::time::Instant;
use async_trait::async_trait;
use dashmap::DashMap;
#[cfg(feature = "perf")]
use perfcnt::*;
use rustcommon_metrics::*;
use tokio::f... | 33.265372 | 109 | 0.442066 |
de00a9427b3e05c7d82a4b0658b3d88aca752a67 | 564 | // if1.rs
pub fn bigger(a: i32, b: i32) -> i32 {
// Complete this function to return the bigger number!
// Do not use:
// - another function call
// - additional variables
// Execute `rustlings hint if1` for hints
if a> b {
a
}else {
b
}
}
// Don't mind this for now :)... | 17.625 | 58 | 0.546099 |
c1122d64b2d53dcedade44319c3efb139b8ed07d | 2,071 | use dson::Dson;
use thir::{Expr, Literal, TypedHir};
use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Error)]
pub enum HirToJsonError {
#[error("{0} not allowed")]
NotAllowed(String),
}
pub fn thir_to_dson(thir: &TypedHir) -> Result<Dson, HirToJsonError> {
let dson = match &thir.expr {
Expr... | 38.351852 | 97 | 0.53549 |
bbb68f46b2a821910e81fb3306a6e7691b644c5d | 1,591 |
#[cfg(target_arch = "x86_64")]
use core::arch::x86_64::{
// info can be found at https://software.intel.com/sites/landingpage/IntrinsicsGuide
__m256i,
// <<
_mm256_slli_epi64,
// >>
_mm256_srli_epi64,
// ^
_mm256_xor_si256,
// mem -> reg
_mm256_loadu_si256,
// reg -> mem
... | 30.596154 | 140 | 0.62665 |
75294dbe55d499edb4c8f890cbe28fe82ef52df1 | 15,083 | //! This crate is for solving instances of the [minimum cost maximum flow problem](https://en.wikipedia.org/wiki/Minimum-cost_flow_problem).
//! It uses the network simplex algorithm from the [LEMON](http://lemon.cs.elte.hu/trac/lemon) graph optimization library.
//!
//! # Example
//! ```
//! use mcmf::{GraphBuilder, ... | 34.673563 | 141 | 0.545846 |
8a2db6ba73025c16d4cae06224790798279f4cb7 | 1,334 | use cssparser::Parser;
use crate::parser::ParseError;
use crate::properties::declaration::PropertyDeclaration;
use crate::properties::declaration_block::SourcePropertyDeclaration;
use crate::stylesheets::stylesheet::ParserContext;
use crate::values::shortcut_for_four_values;
use crate::values::specified::layout::LineS... | 31.761905 | 92 | 0.794603 |
896e16058b884fe113666ec77b4d66c314e3b87b | 845 | use riscv::register::sstatus::{self, Sstatus, SPP};
#[repr(C)]
pub struct TrapContext {
pub x: [usize; 32],
pub sstatus: Sstatus,
pub sepc: usize,
pub kernel_satp: usize,
pub kernel_sp: usize,
pub trap_handler: usize,
}
impl TrapContext {
pub fn set_sp(&mut self, sp: usize) {
self.... | 22.236842 | 51 | 0.504142 |
1aad104644b8cb2fddd92d01cae9f339fbaad243 | 278 | // SPDX-License-Identifier: MIT
/*
* File: src/math/nextafterf.rs
*
* The nextafterf function.
*
* Author: HTG-YT
* Copyright (c) 2021 The LibM Team of the HaruxOS Project
*/
#[no_mangle]
pub extern "C" fn nextafterf(x: f32, y: f32) -> f32 {
libm::nextafterf(x, y)
} | 19.857143 | 58 | 0.651079 |
288cb1ae888e603c6c6b60cd012eceeb277fbaef | 1,811 | use std::sync::Arc;
use crate::{
error::CommandError,
manager::command::{producer::CommandProducer, ClockCommand, Command},
value::Value,
};
use super::{ClockId, ClockShared, ClockTime};
/// Controls a clock.
///
/// When a [`ClockHandle`] is dropped, the corresponding clock
/// will be removed.
pub struct ClockH... | 22.6375 | 89 | 0.675318 |
d95d6b4a31a5724eeaf20858da84848ee09aa27f | 114,361 | #![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use super::{models, models::*, API_VERSION};
pub mod accounts {
use super::{models, models::*, API_VERSION};
pub async fn list(
operation_config: &crate::OperationConfig,
subscript... | 47.630571 | 302 | 0.584089 |
ab86d39d4e946d201edd4d32fc3953650b8b95b1 | 3,477 | #[cfg(not(feature = "mesalock_sgx"))]
use std::fmt;
#[cfg(not(feature = "mesalock_sgx"))]
use std::str::FromStr;
use parity_scale_codec::{Decode, Encode, Error, Input, Output};
use secp256k1::key::PublicKey;
#[cfg(not(feature = "mesalock_sgx"))]
use serde::de;
#[cfg(not(feature = "mesalock_sgx"))]
use serde::{Deserial... | 30.5 | 163 | 0.652862 |
e26604b6aa9d1a238bfa80d418c5efb061c3d69e | 2,650 | //! A CLI tool for converting between table schema formats.
#![forbid(unsafe_code)]
#![warn(
missing_docs,
unused_extern_crates,
clippy::all,
clippy::cargo,
clippy::cast_lossless,
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_precision_loss,
clippy::cast... | 31.927711 | 80 | 0.689811 |
fb0a9d8a2c699a4aa1b35b229138f9bba03d9cbf | 179 | mod callgraph;
mod checker;
mod collector;
mod dataflow;
mod genkill;
mod lock;
mod tracker;
mod report;
mod def_use;
pub use self::checker::DoubleLockChecker;
use super::config;
| 14.916667 | 41 | 0.776536 |
fbdcdc81ae9bb9b8cbb2487068e15fa5f4a344c0 | 21,888 | // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
use deno_core::anyhow::Context;
use deno_core::error::{uri_error, AnyError};
pub use deno_core::normalize_path;
use deno_core::ModuleSpecifier;
use deno_runtime::deno_crypto::rand;
use std::env::current_dir;
use std::fs::OpenOptions;
use std::i... | 29.820163 | 113 | 0.599689 |
08fe77cfddc95eb583f101edca204688ddcbbaa8 | 313 | // strings1.rs
// Make me compile without changing the function signature!
// Execute `rustlings hint strings1` for hints ;)
fn main() {
let answer = current_favorite_color();
println!("My current favorite color is {}", answer);
}
fn current_favorite_color() -> String {
return "blue".to_string()
}
| 24.076923 | 59 | 0.693291 |
214fae02ce27210e3010f41ec6cdda38c2c65fea | 26,870 | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | 28.077325 | 99 | 0.530815 |
147180c2f5fa62e1db1b05ac23b89f20faf5d11c | 5,544 | use ferrysched_shared::imports::*;
use ferrysched_shared::types::*;
static MIN_THRU_FARE_TRANSFER_DURATION: Lazy<Duration> = Lazy::new(|| Duration::minutes(30));
static MAX_THRU_FARE_TRANSFER_DURATION: Lazy<Duration> = Lazy::new(|| Duration::minutes(125));
#[derive(Eq, Ord, PartialEq, PartialOrd)]
pub struct SailingW... | 39.884892 | 116 | 0.61562 |
1ef0b55d3ccc29015d172e44779f54efd07e65b5 | 9,605 | use super::externals::{wasm_extern_t, wasm_extern_vec_t};
use super::module::wasm_module_t;
use super::store::wasm_store_t;
use super::trap::wasm_trap_t;
use crate::ordered_resolver::OrderedResolver;
use std::mem;
use std::sync::Arc;
use wasmer::{Extern, Instance, InstantiationError};
/// Opaque type representing a We... | 31.388889 | 105 | 0.569287 |
e644d8766f1d0e967bd95e978dd8f0c6870628e4 | 10,504 | extern crate midir;
extern crate rosc;
use std::thread;
use std::sync::mpsc;
use std::sync::{Mutex, Arc};
use std::time::{Instant,Duration};
use std::io::{stdin};
use std::error::Error;
use std::env;
use std::net::{UdpSocket, SocketAddrV4};
use rosc::{OscPacket, OscMessage, OscType};
use rosc::encoder;
use midir::{... | 35.367003 | 233 | 0.536177 |
48f9a090b201eaccba57113bee6d95bcf8f99260 | 4,220 | // 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... | 28.707483 | 85 | 0.582938 |
feef894d6dd0855269f4d2056354b365c1c16c3b | 4,222 | #[cfg(feature = "cross-version")]
pub mod compatibility;
#[cfg(all(feature = "network"))]
pub mod network;
/*
Explorer quick test. Run node for ~15 minutes and verify explorer is in sync with node rest
*/
pub mod explorer;
/*
Sanity performance tests. Quick tests to check overall node performance.
Run some transacti... | 31.044118 | 111 | 0.68901 |
ebc454b9d44ab1bcc9d3dc3fd54b45bb7badcb57 | 29,614 | // Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0.
use std::sync::mpsc::channel;
use std::sync::Arc;
use std::time::Duration;
use std::{fs, thread};
use kvproto::metapb;
use kvproto::pdpb;
use kvproto::raft_cmdpb::*;
use kvproto::raft_serverpb::RaftMessage;
use raft::eraftpb::MessageType;
use engine_... | 33.690557 | 99 | 0.651955 |
d72382bd41d8117bdeeaa19e8836ab4e0706607c | 8,344 | use super::prelude::*;
use sink::{Sink, SinkState};
use stream::{BufferAttr, StreamFlags, Stream};
use std::u32;
use std::ffi::CStr;
const INVALID_INDEX: u32 = u32::MAX;
/// Specifies a sink to connect a playback stream to.
///
/// Said sink might not exist (in which case a `NoEntity` error should be returned).
#[d... | 34.479339 | 100 | 0.606663 |
010210eae60db99ff5647ac24751325cbc53f8d4 | 12,835 | //!
//! methods to interact with the rebuild process
use crate::{
context::{Context, OutputFormat},
Error,
GrpcStatus,
};
use ::rpc::mayastor as rpc;
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
use colored_json::ToColoredJson;
use snafu::ResultExt;
use tonic::Status;
pub async fn handler(
... | 26.087398 | 80 | 0.44815 |
614224410d13eb1565c01a2b230d6e18b1e9baac | 28,438 | /*
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 10/07/2017
Last Modified: 10/05/2019
License: MIT
NOTES:
1. This tool is designed to work either by specifying a single input and output file or
a working directory containing multiple input LAS files.
2. Need ... | 41.820588 | 218 | 0.427597 |
117a96d1174041c3079ed9b01d1d2352ec79d840 | 2,897 | // Copyright 2020 Datafuse Labs.
//
// 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 ... | 34.903614 | 93 | 0.625129 |
1cb1dede5519d2c9e11f7cc02b4ec29710ba11f8 | 726 | //! This repo contains a simple framework for building Optics agents.
//! It has common utils and tools for configuring the app, interacting with the
//! smart contracts, etc.
//!
//! Implementations of the `Home` and `Replica` traits on different chains
//! ought to live here.
#![forbid(unsafe_code)]
#![warn(missing_... | 19.105263 | 79 | 0.702479 |
abde43b7db78b86119fc4616cf573bd21b80ee0c | 1,961 | use specs::prelude::*;
use super::{Map, Position, BlocksTile, TileSize};
pub struct MapIndexingSystem {}
impl<'a> System<'a> for MapIndexingSystem {
type SystemData = ( WriteExpect<'a, Map>,
ReadStorage<'a, Position>,
ReadStorage<'a, BlocksTile>,
... | 39.22 | 110 | 0.4564 |
03dc6f36f9a3e607ed63ce3f8d25380c7bb97726 | 721 | // Copyright 2016 Mozilla
//
// 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 writing, software... | 48.066667 | 82 | 0.765603 |
f997762e768c12d149c938b8314937ce2cb28e65 | 2,846 | // Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::unit_tests::testutils::compile_module_string;
#[test]
fn compile_script_with_functions() {
let code = String::from(
"
module Foobar {
resource FooCoin { value: u64 }
public value... | 27.104762 | 83 | 0.550597 |
cc303bfcba3a5c36f75a369db095ecc51c1afcca | 3,374 | // SPDX-License-Identifier: MIT OR Apache-2.0
//
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
//! Printing facilities.
use crate::{bsp, console};
use core::fmt;
//--------------------------------------------------------------------------------------------------
// Private Code
//-------------... | 30.396396 | 100 | 0.504149 |
56a0392e611fb1e7a45481dc18600f128adb20fb | 9,905 | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::MAC_DEBUG {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = r" Value of the field"]
pub struct RXIDLESTATR {
... | 28.877551 | 287 | 0.546795 |
1c8dc82d88f9699fcb257adaf1cf3ea27d75b158 | 98 | pub mod pda;
pub mod state;
pub mod transition;
pub use self::{pda::*, state::*, transition::*};
| 16.333333 | 48 | 0.653061 |
e608a7d22dcf5e8a8fe33bf3fbf969974157ae93 | 83,287 | // 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 ... | 28.699862 | 99 | 0.488516 |
56a29ea3958bda0b468f92caa60130a2ca284e2d | 81,857 | #![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use super::{models, API_VERSION};
#[derive(Clone)]
pub struct Client {
endpoint: String,
credential: std::sync::Arc<dyn azure_core::TokenCredential>,
scopes: Vec<String>,
pipeline: azure_c... | 50.280713 | 138 | 0.516364 |
877d179043dd3db56fcc19bbb962647f189fdc54 | 973 | #[macro_use] extern crate log;
use kube::{
api::{Api, Reflector},
client::APIClient,
config,
};
/// Example way to read secrets
fn main() -> Result<(), failure::Error> {
std::env::set_var("RUST_LOG", "info,kube=trace");
env_logger::init();
let config = config::load_kube_config().expect("failed ... | 29.484848 | 84 | 0.587873 |
ab6f2ae630ef4b6dc37a5e914665cb9442d1b704 | 3,396 | //! A tiny crate of utilities for working with implicit Wasm codegen conventions
//! (often established by LLVM and lld).
//!
//! Examples conventions include:
//!
//! * The shadow stack pointer
//! * The canonical linear memory that contains the shadow stack
#![deny(missing_docs, missing_debug_implementations)]
use ... | 35.375 | 90 | 0.621319 |
71b15321a441b76ad7f5876e92f02a46dcd5734c | 1,339 |
use crate::types::*;
use crate::errors::*;
/// Contains a list of chat lists
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ChatLists {
#[doc(hidden)]
#[serde(rename(serialize = "@type", deserialize = "@type"))]
td_name: String,
/// List of chat lists
chat_lists: Vec<ChatList>,
}
... | 20.921875 | 106 | 0.660194 |
fc4c3a2eb2ef8417d8e608a5f337d0f515160fcf | 371 | // if1.rs
pub fn bigger(a: i32, b: i32) -> i32 {
if a > b {
return a
}
b
}
// Don't mind this for now :)
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn ten_is_bigger_than_eight() {
assert_eq!(10, bigger(10, 8));
}
#[test]
fn fortytwo_is_bigger_than_thirtytwo()... | 14.269231 | 44 | 0.512129 |
e62a91af40fa87ae5fd394337bc38ae147ea971a | 6,342 | use crate::{
cmd::*,
result::{anyhow, Result},
traits::{TxnEnvelope, TxnSign, B64},
};
use helium_api::blocks;
use rust_decimal::{prelude::*, Decimal};
use serde::Serialize;
use serde_json::json;
use std::str::FromStr;
/// Report an oracle price to the blockchain
#[derive(Debug, StructOpt)]
pub enum Cmd {
... | 30.936585 | 97 | 0.519237 |
038471afd8dc70e65ba54922a437a68f0e9ccab2 | 5,744 | use cargo_metadata::{DependencyKind, Metadata, Node, Package, PackageId, Version};
use std::collections::{HashMap, HashSet, VecDeque};
use std::fmt;
/// A pattern for matching package names in a [Rule].
pub enum PackageSpec {
/// Match all packages.
Wildcard,
/// Match packages with the specified name.
... | 31.217391 | 87 | 0.535515 |
db30a23b89da17bcd9751a053707b519b4ac01ab | 3,101 | use std::{
collections::HashMap,
fmt::{self, Debug, Formatter},
};
use crate::{consts, util};
// Headers names which may contain more than one value.
const MULTI_VALUE_HEADER_NAMES: &[&str] = &[
consts::H_ACCEPT,
consts::H_ACCEPT_CHARSET,
consts::H_ACCEPT_ENCODING,
consts::H_ACCEPT_LANGUAGE,
... | 33.344086 | 114 | 0.620767 |
e906af47cf50127d2ffa5755f093d729e1d8e008 | 419 | use std::collections::HashMap;
fn main() {
let mut original = HashMap::new();
original.insert("name", "Rocket Skates");
original.insert("price", "12.75");
original.insert("color", "yellow");
let mut update = HashMap::new();
update.insert("price", "15.25");
update.insert("color", "red");
... | 23.277778 | 45 | 0.596659 |
4af11ad234e45436429802a0d53ce3765a06712c | 3,813 | #[global_allocator]
static ALLOCATOR: jemallocator::Jemalloc = jemallocator::Jemalloc;
use std::sync::mpsc::channel;
use std::time::{Duration, Instant};
use timely::Configuration;
use differential_dataflow::operators::{Consolidate, Count};
use declarative_dataflow::plan::{Aggregate, AggregationFn, Join, Union};
use... | 35.971698 | 98 | 0.469709 |
38414bcd6afa7fde611b9192f0aaa36fe3a7411c | 547 | table! {
members (user_id, project_id) {
user_id -> Uuid,
project_id -> Uuid,
permission -> Varchar,
}
}
table! {
projects (id) {
id -> Uuid,
name -> Varchar,
archived -> Bool,
}
}
table! {
users (id) {
id -> Uuid,
name -> Varchar,
... | 16.088235 | 44 | 0.52468 |
d57e9c8d1a2df40a55b150ed926e47d8b24b74a5 | 1,996 | use rustc_hash::FxHashMap;
use roller_protocol::control::{ButtonCoordinate, ButtonGridLocation, FaderId};
use crate::control::{
button::{ButtonGroup, ButtonMapping, ButtonRef, MetaButtonMapping},
fader::FaderControlMapping,
};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ControlMapping {
pub faders:... | 34.413793 | 91 | 0.601202 |
d75f124a22fc4b25f9826c6e8e76acd6007cad30 | 10,565 | // Copyright 2019 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use super::constants::*;
use super::evdev::{grab_evdev, ungrab_evdev};
use super::virtio_input_event;
use super::InputError;
use super::Result;
use dat... | 31.537313 | 100 | 0.613441 |
389c3e699a867dcfa774078aec7143ed29a1aa40 | 15,106 | //! Board support crate for the Nordic nRF52840-DK
//!
//! UARTE, SPIM and TWI should be functional,
//! but might miss some features.
#![no_std]
pub use cortex_m;
pub use embedded_hal;
pub use nrf52840_hal as hal;
/// Exports traits that are usually needed when using this crate
pub mod prelude {
pub use nrf52840... | 26.317073 | 106 | 0.564742 |
dd52898652e21bc998dce1d09fecd49e49662b68 | 3,510 | // Copyright 2019 The Druid Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed... | 34.07767 | 98 | 0.505983 |
d956f26d52c9a0636fa855f56587d60351652ccc | 26,399 | use std::{
cell::Cell,
cmp,
cmp::min,
io::{self, Write},
sync::{Mutex, RwLock},
};
use crossbeam::sync::MsQueue;
use scoped_threadpool::Pool;
use glam::Vec4;
use crate::{
accel::ACCEL_NODE_RAY_TESTS,
color::{map_0_1_to_wavelength, SpectralSample, XYZ},
fp_utils::robust_ray_origin,
... | 37.712857 | 100 | 0.42638 |
71ec289a084e87f454fa4b25e7c0614eaa3dde37 | 722 | pub struct AssetPaths {
pub fira_sans: &'static str,
pub audio_birds: &'static str,
pub texture_tree: &'static str,
pub texture_wood_logs: &'static str,
pub texture_house: &'static str,
pub texture_man: &'static str,
pub texture_grad_shadow: &'static str,
pub texture_stockpile: &'static ... | 32.818182 | 52 | 0.699446 |
6ad3ec67b29642bb251aef0cae43a3c216b2fe1f | 573 | // 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 ... | 30.157895 | 68 | 0.720768 |
8a249287adadc9c168ef2f6ed061ecc332dc1f53 | 947 | use std::{
ops::{Deref, Range},
rc::Rc,
};
pub struct SharedSlice<T> {
inner: Rc<[T]>,
start: usize,
end: usize,
}
impl<T> SharedSlice<T> {
pub fn new(slice: Box<[T]>) -> Self {
let start = 0;
let end = slice.len();
Self {
inner: slice.into(),
st... | 18.94 | 76 | 0.432946 |
89ee43906b678d13975c335043bb8a2741d42514 | 11,413 | use anyhow::anyhow;
use scraper::{element_ref, html};
use serde::{Deserialize, Serialize};
use std::{collections, str};
lazy_static::lazy_static! {
static ref TR: scraper::Selector = scraper::Selector::parse("tr").unwrap();
static ref TD: scraper::Selector = scraper::Selector::parse("td").unwrap();
static ... | 32.702006 | 97 | 0.554193 |
0a38ab69f4290753c638e31b1e91345017a33319 | 75,214 | #[cfg(not(target_os = "dragonfly"))]
use libc;
use libc::c_int;
use std::{fmt, io, error};
use {Error, Result};
pub use self::consts::*;
cfg_if! {
if #[cfg(any(target_os = "freebsd",
target_os = "ios",
target_os = "macos"))] {
unsafe fn errno_location() -> *mut c_int {
... | 39.153566 | 152 | 0.500425 |
91acf5b03a37231e940c5a79882c2981e62c4dfe | 153,817 | mod error;
mod helpers;
mod impl_debug;
mod impl_partialeq;
pub mod struct_layout;
#[cfg(test)]
#[allow(warnings)]
pub(crate) mod bitfield_unit;
#[cfg(all(test, target_endian = "little"))]
mod bitfield_unit_tests;
use self::helpers::attributes;
use self::struct_layout::StructLayoutTracker;
use super::BindgenOptions;... | 33.547874 | 137 | 0.478127 |
0e271aac1d543038c294a374f65c98530de0e23c | 623 | use seed::{prelude::*, *};
use super::{solid_trait_private::SolidPrivate, Solid};
pub struct LockOpen;
impl SolidPrivate for LockOpen {
fn base<T>(classes: impl ToClasses) -> Node<T> {
svg![
C![classes],
attrs!(
At::from("fill") => "currentColor",
At::from(... | 27.086957 | 171 | 0.516854 |
33a9c9b67d46e70a068438181e5dd15b37cb91fd | 4,718 | use arrow::array::ArrayDataBuilder;
use arrow::array::StringArray;
use arrow::buffer::Buffer;
use num_traits::{AsPrimitive, FromPrimitive, Zero};
use std::fmt::Debug;
/// A packed string array that stores start and end indexes into
/// a contiguous string slice.
///
/// The type parameter K alters the type used to sto... | 27.114943 | 97 | 0.570369 |
90c17a94a576f0b6c57937717fc9a3f22e488110 | 611 | //! Macros for NuttX
//! Based on https://github.com/no1wudi/nuttx.rs/blob/main/src/macros.rs
/// Print a formatted message to the serial console
#[macro_export]
macro_rules! println {
// If no parameters, print a empty string
() => {
$crate::puts_format(format_args!(""))
};
// If 1 parameter... | 32.157895 | 82 | 0.605565 |
ab6259088f150fea724691fad4e6502a50df3112 | 8,699 | #![allow(dead_code)]
#![allow(non_snake_case)]
#![deny(unused_must_use)]
#[cfg(feature = "mcu")]
use rustBoot::constants::{BOOT_PARTITION_ADDRESS, PARTITION_SIZE, UPDATE_PARTITION_ADDRESS};
use std::{env, path::PathBuf};
// use std::path::Path;
use xshell::cmd;
#[rustfmt::skip]
fn main() -> Result<(), anyhow::Error>... | 39.184685 | 139 | 0.540867 |
1ef5e22bce236c426d8f4b544a1e28f3f623ff14 | 3,543 | use futures_util::{Stream, StreamExt as _};
use opentelemetry::global;
use opentelemetry::global::shutdown_tracer_provider;
use opentelemetry::sdk::trace::Config;
use opentelemetry::sdk::{metrics::PushController, trace as sdktrace, Resource};
use opentelemetry::trace::TraceError;
use opentelemetry::{
baggage::Bagga... | 34.067308 | 91 | 0.646345 |
db9d22f14cbfb5fc1a71b1d502cfe23a29b8e768 | 1,883 | // Copyright 2021 Datafuse Labs.
//
// 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 ... | 35.528302 | 75 | 0.832714 |
7595360a1399cfeb354f8c6ef0a2d3f2b95215f9 | 516 | use iced::Subscription;
use pyo3::prelude::*;
use super::ToSubscription;
use crate::app::Interop;
use crate::common::{GCProtocol, Message};
pub(crate) fn init_mod(_py: Python, _m: &PyModule) -> PyResult<()> {
Ok(())
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub(crate) struct NoSubscription;... | 23.454545 | 76 | 0.697674 |
50d2efcb9955286b1be223940eb9c158480d8b7f | 1,750 | // Update of https://github.com/ajungren/crc32_digest to work with digest v0.9
#![forbid(unsafe_code)]
use crc32fast::Hasher as Crc32Hasher;
use std::hash::Hasher as HasherTrait;
use std::convert::TryInto;
use digest::{impl_write, FixedOutput, Update, Reset};
use generic_array::typenum::U4;
use generic_array::GenericA... | 26.923077 | 89 | 0.637714 |
16b6f48ce77a64321004c28731e8109dab525b0a | 4,756 | // Copyright (c) 2015 Alcatel-Lucent, (c) 2016 Nokia
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice,... | 31.496689 | 87 | 0.648024 |
918e43d040cb595084a8f28da327e5721224813e | 1,397 | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | 22.901639 | 68 | 0.651396 |
e9da8beb1fec87dfa657fef2caed44bf51b6cfc0 | 893 | use gaiku_common::{prelude::*, Result};
use image::load_from_memory;
/// Converts a `png` file to 2d chunk data.
pub struct PNGReader;
impl FileFormat for PNGReader {
type Value = (u8, u8);
fn load<C, T>(bytes: Vec<u8>) -> Result<(Vec<C>, Option<TextureAtlas2d<T>>)>
where
C: Chunkify<Self::Value> + Chunki... | 24.805556 | 88 | 0.590146 |
618cce8187ff3ff109e1e2d5accf13ad08f95059 | 3,011 | use std::collections::VecDeque;
use common::{math, proto::Position};
/// Predicts the result of motion inputs in-flight to the server
///
/// When sending input to the server, call `push` to record the input in a local queue of in-flight
/// inputs, and to obtaining a generation tag to send alongside the input. The s... | 33.087912 | 99 | 0.610428 |
4ba127e38d5dcabbeeccef735c0a67de43098216 | 11,603 | // Copyright 2018 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::{
packet_logs::{append_pcap, write_pcap_header},
*,
},
async_utils::PollExt,
fidl::{endpoints::RequestStream, ... | 36.602524 | 95 | 0.670602 |
e56a4359d1822890283ef4d39d37274ca567862c | 1,431 | use clap::{App, Arg};
use std::fs;
use std::io::{self, Write};
use rlox::vm::compiler;
use rlox::vm::vm;
fn main() {
let matches = App::new("My Super Program")
.arg(
Arg::with_name("trace")
.long("trace")
.help("Trace execution"),
)
.arg(Arg::wit... | 27 | 92 | 0.559748 |
bf99759b192cc00cbba1083140390ddd8f3fb266 | 357 | #![cfg_attr(not(with_main), no_std)]
fn f (x : u32) -> u32 {
let mut k = 0;
loop {
if k == x {
break;
}
k = k+1;
}
return k;
}
const ARG :u32 = 2;
#[cfg(with_main)]
pub fn main() {
println!("{:?}", f(ARG));
}
#[cfg(not(with_main))] #[cfg_attr(crux, crux_tes... | 17 | 84 | 0.462185 |
0aeebae639e91811cfcda603e03fb34b96f42521 | 757 | #![feature(type_alias_impl_trait)]
trait IterBits {
type BitsIter: Iterator<Item = u8>;
fn iter_bits(self, n: u8) -> Self::BitsIter;
}
type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>;
impl<T: Copy, E> IterBits for T
where
T: std::ops::Shr<Output = T>
+ std::ops::BitAnd<T, Output =... | 28.037037 | 100 | 0.586526 |
62c992e10ed0dfd34147d1f453322285b264e6fa | 1,341 | use rgx::math::Point2;
use rgx::rect::Rect;
pub fn clamp(p: &mut Point2<i32>, rect: Rect<i32>) {
if p.x < rect.x1 {
p.x = rect.x1;
}
if p.y < rect.y1 {
p.y = rect.y1;
}
if p.x > rect.x2 {
p.x = rect.x2;
}
if p.y > rect.y2 {
p.y = rect.y2;
}
}
pub fn stit... | 22.35 | 97 | 0.480239 |
e54b11858cd1c7e6d00f42fb3e631c6e2bb367e6 | 3,066 | #[doc = "Register `TASKS_START` writer"]
pub struct W(crate::W<TASKS_START_SPEC>);
impl core::ops::Deref for W {
type Target = crate::W<TASKS_START_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl core::ops::DerefMut for W {
#[inline(always)]
fn deref_mut(&mut... | 32.967742 | 392 | 0.620678 |
f566c6ad49d0580890a1c4bd39230e09cd698d5d | 59,165 | use crate::parser::filter::{MatchTarget, ModifierMap};
use graph_core::resource::ResourceIdentity;
pub fn get_target_map_modifier(resource_identity: ResourceIdentity) -> ModifierMap {
let mut modify_target = ModifierMap::default();
match resource_identity {
ResourceIdentity::Activities => {
... | 46.114575 | 100 | 0.520274 |
9ce92c08fde253a2bf8b1dd4d9a01222af650d2d | 1,246 | pub enum SchemaVersion {
Schema0,
Schema1,
Unknown,
}
#[derive(PartialEq)]
pub enum ClientHandshakeState {
WriteC0C1,
ReadS0S1S2,
WriteC2,
Finish,
}
#[derive(Copy, Clone)]
pub enum ServerHandshakeState {
ReadC0C1,
WriteS0S1S2,
ReadC2,
Finish,
}
pub const RTMP_VERSION: usize ... | 32.789474 | 99 | 0.682183 |
160e7002fe940117f889fd74d0569c5c7b61193b | 1,795 | struct Point { x: i32, y: i32, z: i32 }
pub fn main() {
let mut point = Point { x: 0, y: 0, z: 0 };
{
let borrowed_point = &point;
let another_borrow = &point;
// Data can be accessed via the references and the original owner
println!("Point has coordinates: ({}, {}, {})",
... | 33.240741 | 78 | 0.588301 |
874d36e83a716e9abca8b9b4e7f38aa247c27637 | 289 | // Copyright 2020 justjavac. All rights reserved. MIT license.
use anyhow::Result;
use crate::version::get_local_versions;
pub fn exec() -> Result<()> {
let mut versions = get_local_versions();
versions.sort();
versions.reverse();
println!("{}", versions.join("\n"));
Ok(())
}
| 22.230769 | 62 | 0.66782 |
9bd48352b070505d5f6bfd027051e58fb3db41de | 827 | #![feature(proc_macro_hygiene)]
#[macro_use] extern crate rocket;
#[cfg(test)] mod tests;
use std::sync::atomic::{AtomicUsize, Ordering};
use rocket::State;
use rocket::response::content;
struct HitCount(AtomicUsize);
#[get("/")]
fn index(hit_count: State<'_, HitCount>) -> content::Html<String> {
hit_count.0.... | 22.972222 | 67 | 0.633615 |
9c8708bbe5e055d3439a479aa47f99247eb00195 | 608 | use crate::{wl_split_timer::WlSplitTimer, TimerDisplay};
use std::{
error::Error,
sync::{Arc, Mutex},
};
pub struct App {
timer: Arc<Mutex<WlSplitTimer>>,
}
impl App {
pub fn new(timer: WlSplitTimer) -> Self {
Self {
timer: Arc::new(Mutex::new(timer)),
}
}
}
impl TimerD... | 19.612903 | 56 | 0.537829 |
ff9dfa71db7628ab6bc7c7ef8ea6b968dfa88104 | 151,678 | // Copyright 2019 The vault713 Developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or a... | 30.232808 | 150 | 0.674514 |
3abe7626efc6ef922a277dcec9c17df2664e8090 | 35,571 | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | 39.089011 | 100 | 0.54626 |
fe6845a9077c9a14f98faa420ed36de46aa57084 | 2,815 | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | 38.040541 | 163 | 0.685258 |
6980571c1f7cf8d7b5d37b9c3334031c421c2e17 | 10,593 | use std::ops::{Add, Div, Mul, Sub};
#[derive(Debug)]
pub struct Matrix<T: Add + Sub + Copy> {
pub items: Vec<Vec<T>>,
pub rows: usize,
pub cols: usize,
}
impl<T: Add + Sub + Mul + Div + Copy> Matrix<T> {
pub fn new(vecs: Vec<Vec<T>>) -> Option<Matrix<T>> {
let mut same_cols = true;
let... | 28.707317 | 100 | 0.436798 |
671fd4b904781725923543e944b3b939abb0dbf1 | 259 | #[macro_use]
extern crate diesel;
use diesel::*;
use diesel::dsl::count_star;
table! {
users {
id -> Integer,
}
}
fn main() {
use self::users::dsl::*;
let source = users.select((id, count_star()));
//~^ ERROR MixedAggregates
}
| 13.631579 | 50 | 0.57529 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.