blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
f8ef710c9faab2d57e76ec77b94a3463786927c5 | Rust | iCodeIN/throttle | /server/tests/client.rs | UTF-8 | 12,776 | 3.28125 | 3 | [
"MIT"
] | permissive | mod common;
use common::Server;
use std::{collections::HashMap, time::Duration};
use tokio::time::timeout;
/// `client.acquire` if called in a non-blocking fashion, must return `true` if the lock can be
/// acquired immediatly and `false` otherwise. This must also be in affirmed by subsequent calls
/// to `client.i... | true |
28110f710119b46e9b477db481de0596fb581fb7 | Rust | sendilkumarn/svelte | /parser/wasm.rs | UTF-8 | 20,533 | 2.78125 | 3 | [] | no_license | use super::Parse;
use failure::{self, ResultExt};
use ir;
use parity_wasm::elements;
use std::fmt::Write;
fn serialized_size<T>(t: T) -> Result<u32, failure::Error>
where
T: elements::Serialize,
<T as elements::Serialize>::Error: failure::Fail,
{
let mut buf = vec![];
t.serialize(&mut buf)
.con... | true |
923508c57978a391bb9b4bccc537117adafd336b | Rust | retrhelo/psicasbi | /src/hal/uart/mod.rs | UTF-8 | 1,429 | 2.703125 | 3 | [
"MIT"
] | permissive | // the abstraction of UART
#[cfg(feature = "qemu")]
mod qemu;
#[cfg(feature = "k210")]
mod k210;
use core::option::Option;
use alloc::boxed::Box;
use core::fmt;
trait UartHandler: fmt::Write {
fn getchar(&mut self) ->u8;
fn putchar(&mut self, c: u8);
}
static mut UART_INST: spin::Mutex<Option<Box<dyn UartHandler... | true |
ed55b57532b2ad3afea82621ca3507e7e470e236 | Rust | zeroexcuses/makepad | /examples/editor_example/app/src/lib.rs | UTF-8 | 1,327 | 2.6875 | 3 | [
"MIT"
] | permissive | use makepad_render::*;
use makepad_widget::*;
use makepad_code_editor::*;
pub struct EditorExampleApp {
desktop_window: DesktopWindow,
menu: Menu,
code_editor:CodeEditor,
}
impl EditorExampleApp {
pub fn new(cx: &mut Cx) -> Self {
Self {
desktop_window: DesktopWindow::ne... | true |
8f4b2e7c6309e4cbb93fab55af7380d10690ccbd | Rust | manute/rawsql | /examples/postgre.rs | UTF-8 | 1,096 | 3.09375 | 3 | [
"MIT"
] | permissive | extern crate postgres;
extern crate rawsql;
use postgres::{Client, NoTls};
use rawsql::Loader;
struct Person {
id: i32,
name: String,
data: Option<Vec<u8>>,
}
fn main() {
let mut conn = Client::connect("postgres://postgres:local@localhost", NoTls).unwrap();
let queries = Loader::get_queries_from... | true |
a91a248f7033e3a9ec9007cc31ac66320b0b987d | Rust | sigp/lighthouse | /consensus/state_processing/src/per_slot_processing.rs | UTF-8 | 3,749 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use crate::upgrade::{upgrade_to_altair, upgrade_to_bellatrix, upgrade_to_capella};
use crate::{per_epoch_processing::EpochProcessingSummary, *};
use safe_arith::{ArithError, SafeArith};
use types::*;
#[derive(Debug, PartialEq)]
pub enum Error {
BeaconStateError(BeaconStateError),
EpochProcessingError(EpochProc... | true |
9309658f56a8610435b4157b7ba28148ff532b17 | Rust | yuval-k/connect | /src/animations/idle.rs | UTF-8 | 5,990 | 2.875 | 3 | [] | no_license | use std;
use palette;
use rand;
use std::ops::Rem;
const LED_ANIM_DURATION: u64 = 10;
fn to_float(t: std::time::Duration) -> f32 {
t.as_secs() as f32 + t.subsec_nanos() as f32 / 1_000_000_000.0
}
#[derive(Copy,Clone,Debug)]
pub struct AnimPhase {
total_time: f32,
current_pos: f32, // between 0 and 1
}
... | true |
a1f975094da9dca2286429418cb1e9f8b3fabf3f | Rust | netwarex/tsclientlib | /tsproto-commands/src/codec.rs | UTF-8 | 2,162 | 2.78125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! This module contains a stream and a sink which convert Packets to Commands.
use std::cell::RefCell;
use std::rc::Rc;
use futures::{future, Sink, stream, Stream};
use slog::Logger;
use tsproto::commands::Command;
use tsproto::connection::Connection;
use tsproto::connectionmanager::ConnectionManager;
use tsproto::er... | true |
288cd6481532900ee1a1e3a900249784c7c9e4cb | Rust | pengguoguo/bitbox02-firmware | /src/rust/bitbox02-rust/src/lib.rs | UTF-8 | 1,967 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2019 Shift Cryptosecurity AG
//
// 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 ... | true |
7f5b46affab162b09d0512b1800feffe12314c3d | Rust | doytsujin/amethyst-imgui | /examples/demo_custom_texture.rs | UTF-8 | 2,506 | 2.53125 | 3 | [] | no_license | extern crate amethyst;
extern crate amethyst_imgui;
use amethyst::{
assets::{AssetLoaderSystemData, AssetStorage, Handle, Loader},
ecs::prelude::*,
input::{InputBundle, StringBindings},
prelude::*,
renderer::{
bundle::RenderingBundle,
rendy::texture::image::{self, load_from_image},
types::{DefaultBackend, Te... | true |
f4a922fb2d5ec4ae25b6ecc651c49e3336d359ae | Rust | KwinnerChen/rust_repo | /workspace_learning/borrowing_match/src/main.rs | UTF-8 | 653 | 3.640625 | 4 | [] | no_license | #![allow(dead_code)]
#[derive(Debug)]
enum Food {
Cake,
Pizza,
Salad,
}
#[derive(Debug)]
struct Bag {
food: Food
}
struct Number<'a> {
num: &'a u8
}
impl <'a> Number<'a> {
fn get_num(&self) -> &u8 {
self.num
}
fn set_num(&mut self, new_num: &'a u8) {
self.num = new_nu... | true |
fb72d2882ade6013ef5bb8c2582f07fcb40f37aa | Rust | rust-lang/rust-analyzer | /crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs | UTF-8 | 2,986 | 3.0625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
use hir::HirDisplay;
// Diagnostic: moved-out-of-ref
//
// This diagnostic is triggered on moving non copy things out of references.
pub(crate) fn moved_out_of_ref(ctx: &DiagnosticsContext<'_>, d: &hir::MovedOutOfRef) -> Diagnostic {
Diagnostic::new_with... | true |
e93d27891ba20d1a4d5c03ab29fb2ecfb90ff585 | Rust | bbrener1/smooth_density_graph | /src/io.rs | UTF-8 | 23,303 | 2.71875 | 3 | [] | no_license | use std::fs::File;
use std::fs::OpenOptions;
use std::io::Error;
use std::io;
use std::io::prelude::*;
use std::collections::HashMap;
use num_cpus;
use std::f64;
use std::fmt::Debug;
use rayon::prelude::*;
use std::cmp::Ordering;
use ndarray::{Array,ArrayView,Ix1,Ix2,Axis};
// use ndarray_linalg::*;
#[derive(Debug,C... | true |
4a6e2b1590a3d1ce0450813ff2ae0d43ee1a89b1 | Rust | scampi/falcon | /src/interpreter/functions/builtins.rs | UTF-8 | 1,770 | 2.890625 | 3 | [
"MIT"
] | permissive | //! Evaluates AWK's reserved functions.
use crate::{
errors::EvaluationError,
interpreter::{rnd::Rnd, stmt::formatting::sprintf, value::Value, RuntimeMut},
parser::ast::ExprList,
};
use std::io::Write;
/// Returns true if the given name is a builtin.
pub fn is_builtin(name: &str) -> bool {
match name {... | true |
2803d3de2453ca1cf920d355d6068933019bafc2 | Rust | rukai/canon_collision | /canon_collision/src/graphics.rs | UTF-8 | 2,290 | 2.84375 | 3 | [
"MIT"
] | permissive | use crate::game::RenderGame;
use crate::menu::RenderMenu;
use canon_collision_lib::entity_def::CollisionBoxRole;
use canon_collision_lib::package::PackageUpdate;
pub struct GraphicsMessage {
pub render: Render,
pub package_updates: Vec<PackageUpdate>,
}
pub struct Render {
pub command_output: Vec<String>,... | true |
0862b85ae8f0d16780bd3f057847417eb013fe16 | Rust | hareq/bugu | /os/src/mmu/address.rs | UTF-8 | 5,620 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | pub const PAGE_SIZE: usize = 0x1000;
pub const PAGE_SIZE_BITS: usize = 0xc; //12 bit
use super::PageTableEntry;
use core::fmt::{self, Debug, Formatter};
/// Definitions
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
pub struct PhysAddr(pub usize);
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
pub str... | true |
b90b5e043d5ef4c8ac838045e65921a39b3edd81 | Rust | ultrasaurus/irc-tokio | /src/lib.rs | UTF-8 | 2,281 | 3.078125 | 3 | [
"MIT"
] | permissive | pub mod error;
mod message;
use tokio::prelude::*;
use tokio::{io::BufReader, net::TcpStream};
pub use crate::message::Message; // Re-export `Message` as part of irc module
use crate::error::Error;
type LineHandler = fn(line: &Message) -> ();
struct LineHandlerInfo {
#[allow(dead_code)]
label: String,
f: Line... | true |
37f55128244e994ef7fddb3aa3dfd3a5b2c5889b | Rust | PocketOfWeird/farmstudy | /src/bk_main.rs | UTF-8 | 1,492 | 2.578125 | 3 | [] | permissive | #![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
#[macro_use]
extern crate rocket_contrib;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
use uuid::Uuid;
use rocket::http::Status;
use rocket_contrib::databases::rusted_cypher::{GraphClient, GraphError};
use rocket_contrib... | true |
6ca86ae76ec406fbcefea43b568610819650bb17 | Rust | Schenk75/Learn-Rust | /leetcode-by-rust/LCOF/lcof53-2-0到n-1中缺失的数字/src/main.rs | UTF-8 | 606 | 3.484375 | 3 | [] | no_license | struct Solution;
impl Solution {
pub fn missing_number(nums: Vec<i32>) -> i32 {
// 二分法
let (mut left, mut right) = (0, (nums.len()-1) as i32);
while left <= right {
let mid = left + (right - left) / 2;
if nums[mid as usize] > mid {right = mid - 1;}
else ... | true |
b8420129d2639e114364b6b64f010ddb9339af0f | Rust | kenkoooo/nes-rs | /src/ui/gameview.rs | UTF-8 | 934 | 2.71875 | 3 | [] | no_license | use crate::nes::console::Console;
use crate::ui::util;
use gl;
use glfw::Window;
pub struct GameView {
pub window: Window,
console: Console,
title: String,
hash: String,
texture: u32,
record: bool,
}
impl GameView {
pub fn new(window: Window, console: Console, title: String, hash: String) ... | true |
d971cbb9071c966896e0d7a0da6f6d4c9cca8df6 | Rust | zxt1996/Practice-once-a-day | /LeetCode-Rust/217.存在重复元素/one.rs | UTF-8 | 552 | 3.109375 | 3 | [] | no_license | use std::collections::HashMap;
impl Solution {
pub fn contains_duplicate(nums: Vec<i32>) -> bool {
let mut map = HashMap::new();
for i in 0..nums.len() {
let mut temp = 0;
temp = match map.get(&nums[i]) {
Some(&x) => {
2
... | true |
1036d198e8c08cfac08216aebc6d30a1fd7a15cf | Rust | devplayer0/pubsub | /pubsub-common/src/tests.rs | UTF-8 | 6,388 | 2.890625 | 3 | [] | no_license | use std::str::FromStr;
use std::mem::size_of;
use std::sync::Arc;
use std::sync::atomic::{Ordering, AtomicUsize};
use std::time::{Duration, Instant};
use std::thread;
use std::net::{SocketAddr, UdpSocket};
use bytes::{BufMut, BytesMut};
use super::*;
use constants::*;
use util::*;
use timer::*;
use packet::*;
use pro... | true |
3e34068f2ca1ed125a2e070eea9a1a1a7ea0b919 | Rust | KoStard/cryptology_for_beginners_personal | /src/polyalphabetic/hill_digraph/manipulations.rs | UTF-8 | 4,721 | 3.5 | 4 | [] | no_license | use crate::constants::functions::alphabet::{index_to_letter, letter_to_index};
// Using 2x2 matrix
pub struct HillDigraphCipher {
key: Vec<i32>,
inverse: Vec<i32>
}
impl HillDigraphCipher {
pub fn new(key: [i32; 4]) -> Result<Self, String> {
let key: Vec<i32> = key.iter().map(|x| x % 26).collect()... | true |
df4bc5a5f61ed70d381e7c6c8f4d9cc1e4c46468 | Rust | mason0510/rust-stratum-v2 | /stratumv2/src/types/message_type.rs | UTF-8 | 3,936 | 2.75 | 3 | [] | no_license | use crate::error::{Error, Result};
/// MessageType contains all the variations for the byte representation of
/// messages used in message frames.
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum MessageType {
// Common messages
SetupConnection,
SetupConnectionSuccess,
SetupConnectionError,
Channe... | true |
cbdf09ecd413fc3a89ea349e79969f7868fb71ae | Rust | havardh/rust-koans | /about_hashmaps.rs | UTF-8 | 590 | 3.5 | 4 | [] | no_license | use collections::HashMap;
#[test]
fn hashmap_can_map_to_traits() {
trait Getter {
fn get(&self) -> int;
fn set(&mut self, int);
}
struct GetElem { elem: int };
impl Getter for GetElem {
fn get(&self) -> int { return self.elem; }
fn set(&mut self, val: int) { self.elem =... | true |
d906853dc0790a72832f93047660fbb82efffa78 | Rust | thejpster/lm4f120 | /src/timer.rs | UTF-8 | 8,743 | 3.09375 | 3 | [
"MIT"
] | permissive | //! # Timers for the LM4F120H5QR
//!
//! The Stellaris core has six 16/32-bit timers and six 32/64-bit wide timers.
//! Each timer provides two timers that can operate independently, or be
//! chained together to form a single double-width timer. The Cortex-M4 core
//! also its own separate SysTick timer. This is a 24-... | true |
5afe3ec5fe1a437452c912a2139e0baa4526dea0 | Rust | little-dude/ghrs | /src/services/notifications.rs | UTF-8 | 2,905 | 2.921875 | 3 | [] | no_license | use services::chrono::{DateTime, UTC};
#[derive(Default, Debug)]
pub struct Params {
/// If true, show notifications marked as read.
pub all: Option<bool>,
/// If true, only shows notifications in which the user is directly participating or mentioned.
pub participating: Option<bool>,
/// Only show ... | true |
5c63095ea9ac7dd04c185ff77ff87a81b63ceec4 | Rust | AndrewSouthpaw/rust-by-example | /8/fizzbuzz/src/main.rs | UTF-8 | 431 | 3.15625 | 3 | [] | no_license | fn main() {
let mut n = 0;
loop {
n += 1;
if n > 15 {
break;
} else if n == 9 {
println!("Skipping 9");
continue; // skip 9
} else if n % 3 == 0 && n % 5 == 0 {
println!("FizzBuzz {}", n);
} else if n % 3 == 0 {
... | true |
eaf665fd73d2f01788b7a1860363fff17a18093d | Rust | RayanRal/RustBook | /standardlib/src/main.rs | UTF-8 | 718 | 3.296875 | 3 | [] | no_license | use std::collections::HashMap;
fn main() {
let mut v: Vec<i32> = Vec::new();
let v2 = vec![1, 2, 3];
v.push(1);
for i in &v2 {
println!("{}", i)
}
let mut scores_map = HashMap::new();
scores_map.insert(String::from("Blue"), 10);
scores_map.insert(String::from("Red"), 5);
... | true |
20c35538180b15da38d7278fe32cdd7cdea30991 | Rust | tud-fop/rustomata | /search/src/agenda/binary_heap.rs | UTF-8 | 1,873 | 3.078125 | 3 | [
"BSD-3-Clause"
] | permissive | use std::collections::{binary_heap::IntoIter, BinaryHeap};
pub mod weighted {
use crate::agenda::weighted::{RemoveWeight, Weighted, WeightedItem};
use std::iter::FromIterator;
/// An adapter for `BinaryHeap` that orders elements via the weight
/// provided by the implementation of `Weighted`.
pub ... | true |
b27f5c227d16090ee56584f2bf2d6d2365aaa4e6 | Rust | charleszheng44/leader-elect | /src/linked_list.rs | UTF-8 | 2,953 | 3.359375 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use std::cmp::PartialEq;
#[derive(Debug, Serialize, Deserialize)]
pub struct List<T: PartialEq> {
head: Link<T>,
}
#[derive(Debug, Serialize, Deserialize)]
struct Node<T: PartialEq> {
ele: T,
next: Link<T>,
}
type Link<T> = Option<Box<Node<T>>>;
macro_rules! new_box_... | true |
e6cea3884c4a1563703c897f3e06693a38dacd36 | Rust | rust-lang/rust | /src/tools/clippy/tests/ui/map_flatten_fixable.rs | UTF-8 | 2,121 | 2.84375 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | #![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::let_underscore_untyped)]
#![allow(clippy::missing_docs_in_private_items)]
#![allow(clippy::map_identity)]
#![allow(clippy::redundant_closure)]
#![allow(clippy::unnecessary_wraps)]
#![feature(result_flattening)]
fn main() {
// mapping to Option on Iterator
... | true |
9ba0d55cb889a4adf8f984550837ec24698be860 | Rust | wucke13/mavlink-cli | /src/parameters.rs | UTF-8 | 2,716 | 2.859375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::fmt::{self, Display, Formatter};
use std::io;
use mavlink::common::*;
use skim::{prelude::*, DisplayContext, PreviewContext, SkimItem};
use crate::{
definitions::{self, Definition, User},
mavlink_stub::MavlinkConnectionHandler,
util::*,
};
// API
/// Represents a single parameter according to t... | true |
f4c1f5ca1006d7822e7bf0893d25a5801407cdfa | Rust | cthulhua/aoc2020 | /d12/src/main.rs | UTF-8 | 3,229 | 3.53125 | 4 | [] | no_license | use std::error::Error;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn main() -> Result<(), Box<dyn Error>> {
let program = Program::load("input.txt")?;
let mut vm = Vm {
program,
x: 0,
y: 0,
wx: 10,
wy: -1,
instruction_pointer: 0,
};
dbg!(vm.run... | true |
f3a3025aaf7296f4beccdfc2fb86f54d43fa4049 | Rust | doytsujin/googapis | /googapis/genproto/grafeas.v1beta1.rs | UTF-8 | 36,458 | 2.796875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | /// Metadata for any related URL information.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RelatedUrl {
/// Specific URL associated with the resource.
#[prost(string, tag = "1")]
pub url: ::prost::alloc::string::String,
/// Label to describe usage of the URL.
#[prost(string, tag = "2")]
... | true |
31ee714faff330ecfd643fa440ad30ece988ff6e | Rust | sile/yamakan | /src/optimizers/nelder_mead.rs | UTF-8 | 11,093 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | //! Adaptive nelder-mead simplex algorithm.
//!
//! # References
//!
//! - [Implementing the Nelder-Mead simplex algorithm with adaptive parameters][ANMS]
//! - [Nelder-Mead algorithm](http://var.scholarpedia.org/article/Nelder-Mead_algorithm)
//! - [Nelder-Mead Method (Wikipedia)](https://en.wikipedia.org/wiki/Nelder–... | true |
d54fad1a13ec79ea2cd47d749a387e339b7c24ae | Rust | cundd/twostep | /src/clock/clock.rs | UTF-8 | 794 | 2.578125 | 3 | [] | no_license | use super::{ClockResult, ClockTrait, ExternalClock, InternalClock};
use crate::sequence::Sequence;
use crate::serial_wrapper::SerialWrapper;
use arduino_uno::hal::port::mode::InputMode;
pub enum Clock {
#[allow(unused)]
External(ExternalClock),
#[allow(unused)]
Internal(InternalClock),
}
impl ClockTrai... | true |
6378b7b2f9b4e1f9a46ab89f92702efa2ac7c195 | Rust | fnichol/mtoc | /mtoc-parser/src/normalize.rs | UTF-8 | 20,913 | 2.875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Copyright 2019 Fletcher Nichol and/or applicable contributors.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license (see <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be copied, modified, ... | true |
4c87672ffbdfce27b93b0277f4c99b70b3b7c85b | Rust | henkkuli/rp-hal | /rp2040-hal/src/watchdog.rs | UTF-8 | 3,856 | 3 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Watchdog
//!
//! The watchdog is a countdown timer that can restart parts of the chip if it reaches zero. This can be used to restart the
//! processor if software gets stuck in an infinite loop. The programmer must periodically write a value to the watchdog to
//! stop it from reaching zero.
//!
//! See [Chapter 4... | true |
82edcb3f03610786c6dc3c70976a7de46bde23be | Rust | jfredett/advent-2018 | /src/day3.rs | UTF-8 | 5,892 | 3.03125 | 3 | [] | no_license | use std::str;
use std::fmt;
use std::collections::HashMap;
fn parse_u8(input: &[u8]) -> u8 {
let s = str::from_utf8(input).ok().unwrap();
u8::from_str_radix(s, 10).ok().unwrap()
}
fn parse_u16(input: &[u8]) -> u16 {
let s = str::from_utf8(input).ok().unwrap();
u16::from_str_radix(s, 10).ok().unwrap()
... | true |
81085011cdce87276458813006ddc7ec2f30b4fc | Rust | svartalf/rust-battery | /battery/src/platform/freebsd/device.rs | UTF-8 | 3,687 | 2.640625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::convert::AsRef;
use std::fmt;
use super::acpi;
use crate::platform::traits::BatteryDevice;
use crate::units::{ElectricPotential, Energy, Power, ThermodynamicTemperature};
use crate::{Result, State, Technology};
#[derive(Default)]
pub struct IoCtlDevice {
unit: libc::c_int,
state: State,
technolog... | true |
d8706fd138927b3ff9d0a89c262f0adc8089262e | Rust | Christian7573/webrtc | /dtls/src/curve/named_curve.rs | UTF-8 | 1,724 | 3.125 | 3 | [
"MIT"
] | permissive | // https://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-8
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum NamedCurve {
P256 = 0x0017,
P384 = 0x0018,
X25519 = 0x001d,
Unsupported,
}
impl From<u16> for NamedCurve {
fn from(val: u16) -> Self {
match val {
... | true |
14e8fed7c1e6d2fa6c32f6c214df80cd9a92b5a0 | Rust | SebastienGllmt/chain-libs | /chain-impl-mockchain/src/ledger/check.rs | UTF-8 | 8,473 | 2.71875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use super::{Block0Error, Error};
use crate::certificate;
use crate::transaction::*;
use crate::value::Value;
use chain_addr::Address;
macro_rules! if_cond_fail_with(
($cond: expr, $err: expr) => {
if $cond {
Err($err)
} else {
Ok(())
}
};
);
type LedgerCheck = R... | true |
6eda771bbb376d2ef3608e9044c6eff318a3f339 | Rust | tov/split_ext_rs | /src/split_end.rs | UTF-8 | 6,440 | 3.234375 | 3 | [
"BlueOak-1.0.0"
] | permissive | use std::str;
use super::utf8::char_boundaries;
pub trait SplitEnd: Sized {
type Item: Sized;
fn split_first(self) -> Option<(Self::Item, Self)>;
fn split_last(self) -> Option<(Self::Item, Self)>;
fn try_split_first_n(self, n: usize) -> Option<(Self, Self)>;
fn try_split_last_n(self, n: usize)... | true |
b71010840e340c0d7bc88ded7805e5506849d69d | Rust | sathishvinayk/rust_360 | /advanced traits/deref_derefmut.rs | UTF-8 | 1,129 | 3.640625 | 4 | [] | no_license | use std::ops::{Deref, DerefMut};
use std::rc::Rc;
struct Picker<T> {
elements: Vec<T>,
current: usize
}
impl<T> Deref for Picker<T> {
type Target = T;
fn deref(&self) -> &T {
&self.elements[self.current]
}
}
impl<T> DerefMut for Picker<T> {
fn deref_mut(&mut self) -> &mut T {
... | true |
0ce1bead1984aa2acc7103b34f5744a862f84904 | Rust | aGiant/robust_trading.icml2019 | /rstat/src/univariate/continuous/erlang.rs | UTF-8 | 1,785 | 2.84375 | 3 | [
"MIT",
"BSD-3-Clause"
] | permissive | use crate::core::*;
use rand::Rng;
use spaces::continuous::PositiveReals;
use std::fmt;
#[derive(Debug, Clone, Copy)]
pub struct Erlang {
pub k: usize,
pub lambda: f64,
}
impl Erlang {
pub fn new(k: usize, lambda: f64) -> Erlang {
assert_natural!(k);
assert_positive_real!(lambda);
... | true |
68439e8beb82454bed00b09e3f7ea452b8d96570 | Rust | ashishtyagi10/rust | /invaders/src/menu.rs | UTF-8 | 990 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use crate::frame::{Drawable, Frame};
pub struct Menu {
pub options: Vec<String>,
pub selection: usize,
}
impl Menu {
pub fn new() -> Self {
Self {
options: vec![String::from("New game"), String::from("Exit")],
selection: 0,
}
}
pub fn change_option(&mut sel... | true |
f6c70fa0e221f0250c82765da4306e066860f940 | Rust | SnakeSolid/rust-database-monitor | /src/handlers/databases.rs | UTF-8 | 5,323 | 2.546875 | 3 | [
"MIT"
] | permissive | use std::cmp::Ordering;
use std::io::Read;
use serde_json;
use iron::Handler;
use iron::IronResult;
use iron::mime::Mime;
use iron::mime::SubLevel;
use iron::mime::TopLevel;
use iron::Request;
use iron::Response;
use iron::status;
use search::Query;
use state::DatabaseRow;
use state::State;
#[derive(Deserialize, De... | true |
965c3eaa629ce835b4230ea3c4c8bc396c265ff6 | Rust | dave20874/rs_aoc2020 | /src/rain_risk.rs | UTF-8 | 5,480 | 3.28125 | 3 | [] | no_license | use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use lazy_static::lazy_static;
use regex::Regex;
struct Instruction {
op: String,
value: i32,
}
pub struct RainRisk {
instructions: Vec<Instruction>,
}
impl RainRisk {
pub fn load(filename: &str) -> RainRisk {
lazy_static! {
... | true |
47e69f26abc041abc2ce8f4802994c79bc31065b | Rust | solec0der/networker-rust | /src/pinger.rs | UTF-8 | 1,504 | 3.171875 | 3 | [] | no_license | use std::process::Command;
use std::thread;
use std::time::Duration;
pub struct Pinger {
hosts_alive: u8,
hosts: Vec<String>,
}
impl Pinger {
pub fn new() -> Pinger {
Pinger {
hosts_alive: 0,
hosts: Vec::new(),
}
}
pub fn add_host(&mut self, host_address: S... | true |
f691ee1b8c4324d278e33497404f4709faaad862 | Rust | teloxide/teloxide | /crates/teloxide-core/src/payloads/delete_message.rs | UTF-8 | 1,363 | 2.84375 | 3 | [
"MIT"
] | permissive | //! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::{MessageId, Recipient, True};
impl_payload! {
/// Use this method to delete a message, including service messages, with the following limitations:
/// - A message can only be deleted if it was sent less than 48 ... | true |
62b58083430e85a25a62593c683e1fdb78540918 | Rust | Lol3rrr/waswolf | /src/messages/traits.rs | UTF-8 | 2,242 | 2.890625 | 3 | [] | no_license | use std::{
fmt::{Debug, Display},
sync::Arc,
};
use serenity::{
http::Http,
model::{
channel::{Message, Reaction},
id::GuildId,
},
};
use crate::storage::Storage;
#[derive(Clone)]
pub enum TransitionError {
Serenity,
Generic(Arc<dyn Display + Send + Sync + 'static>),
W... | true |
8f4832be749f85611ad9daf91d0e5c9089da42b0 | Rust | mockersf/bitbucket.rs | /src/api.rs | UTF-8 | 2,095 | 3.03125 | 3 | [] | no_license | use crate::internal_api::AuthType;
use crate::repository::Repository;
use crate::requests::ToUrl;
/// Bitbucket API client
#[derive(Debug)]
pub struct API {
url: String,
pub(crate) auth_type: Option<AuthType>,
pub(crate) client: Option<reqwest::blocking::Client>,
}
impl API {
/// new Bitbucket API cl... | true |
ea17861c0d30db6bcfc9b4aa317848b747672976 | Rust | jasonbking/getrandom | /src/solaris.rs | UTF-8 | 3,122 | 2.578125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2018 Developers of the Rand project.
//
// 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. This file may not be copied, modified, or distributed
/... | true |
0dda887a3d4f4146569a79323cf0fe0a695f435a | Rust | safijari/aoc-rust | /src/day4.rs | UTF-8 | 2,159 | 2.890625 | 3 | [] | no_license | use regex::Regex;
use std::collections::{HashMap, HashSet};
use std::fs;
fn make_validators<'a>() -> HashMap<&'a str, Regex> {
return vec![
("hgt", "(([6][0-9]|59|7[0-6])in)|((1[5-8][0-9]|19[0-3])cm)"),
("byr", "([1-2][9][0|2-9][0-9])|(200[0-3])"),
("iyr", "(201[0-9]|2020)"),
("eyr"... | true |
9162084073a63220e52c6bd5125700ea46033a85 | Rust | burakbayramli/books | /Practical_System_Programming_for_Rust_Developers_Eshwarla/Chapter06/miscellaneous/snippet2.rs | UTF-8 | 267 | 2.78125 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::fs::OpenOptions;
fn main() {
// Method 1
let _file1 = File::open("stats1.txt").expect("File not found");
// Method 2
let _file2 = OpenOptions::new()
.write(true)
.create(true)
.open("stats2.txt");
}
| true |
1ff08c3c8b5031429a2dc4f81413e78c79a79286 | Rust | samiBendou/geomath | /src/lib.rs | UTF-8 | 4,631 | 3.65625 | 4 | [
"BSD-3-Clause"
] | permissive | //!
//! geomath is a general purpose maths framework that aims to provide efficient real-time tools for the
//! following domains:
//!
//! * Linear algebra
//! * Computational Geometry
//! * Computer Graphics and Vision
//! * Physics and Kinematics simulation
//! * Numerical simulation
//!
//! It relies on a vast API t... | true |
7abe3ee323c263e61db3ab608f0f1292759d914a | Rust | JAD3N/mc-server | /server/src/chat/component/text.rs | UTF-8 | 1,315 | 3.015625 | 3 | [
"MIT"
] | permissive | use crate::chat::Style;
use crate::util::ToJsonValue;
use super::{Component, ComponentContainer};
#[derive(Clone)]
pub struct TextComponent {
style: Style,
siblings: Vec<ComponentContainer>,
text: String,
}
impl ToJsonValue for TextComponent {
fn to_json(&self) -> Option<serde_json::Value> {
l... | true |
2d2020100ce18b9905f706dc62a4ae2f8b15d0e8 | Rust | azyobuzin/tweetust | /src/lib.rs | UTF-8 | 4,165 | 3.03125 | 3 | [
"MIT"
] | permissive | //! Tweetust is a simple wrapper for Twitter API.
//!
//! # Getting started
//! This is a Twitter API wrapper, so you must lean Twitter API.
//! [Visit the official document](https://dev.twitter.com/).
//!
//! After getting the API key, let's start using tweetust.
//!
//! # How to get the access token
//! See [oauth::r... | true |
0bef2b7f8dc8a51ee5dc584fd6a1e6c79e5a14ab | Rust | utilForever/BOJ | /Rust/11055 - The Biggest Increasing Partial Sequence.rs | UTF-8 | 705 | 3.34375 | 3 | [
"MIT"
] | permissive | use std::io;
fn input_integers() -> Vec<i32> {
let mut s = String::new();
io::stdin().read_line(&mut s).unwrap();
let values: Vec<i32> = s
.as_mut_str()
.split_whitespace()
.map(|s| s.parse().unwrap())
.collect();
values
}
fn main() {
let n = input_integers()[0] ... | true |
e48eab2d8f136cc169f4a3f359474f3ea17b2b8b | Rust | Vrixyz/iron-cors-rs | /examples/allow_any.rs | UTF-8 | 808 | 2.828125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate iron;
extern crate iron_cors;
use iron::{Iron, Handler, Request, Response, IronResult, Chain, status};
use iron_cors::CorsMiddleware;
struct HelloWorldHandler;
impl Handler for HelloWorldHandler {
fn handle(&self, _: &mut Request) -> IronResult<Response> {
Ok(Response::with((status::Ok, "Hel... | true |
bec3bc6feb90ca20ef83ba72a0b20007f59e1507 | Rust | Chair-of-Indefinite-Studies/scratchapixel | /scratchapixel/examples/use_ppm.rs | UTF-8 | 961 | 2.984375 | 3 | [
"MIT"
] | permissive | extern crate scratchapixel;
use std::fs::File;
use scratchapixel::ppm::rgb::RGB;
use scratchapixel::ppm::format::PPM;
fn main() {
let white = RGB { r: 255, g: 255, b: 255 };
let black = RGB { r: 0, g: 0, b: 0 };
let red = RGB { r: 255, g: 0, b: 0 };
let mut image: PPM = PPM::new(64, 64);
for y... | true |
133b78d7adf4127ed9188c5344b89bd1f5e71724 | Rust | reedrosenbluth/oscen | /oscen-lib/src/midi.rs | UTF-8 | 5,837 | 2.78125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::rack::*;
use crate::utils::interp;
use crate::{build, props, tag};
use crossbeam::channel::Sender;
use midir::{Ignore, MidiInput};
use pitch_calc::calc::hz_from_step;
use std::error::Error;
use std::io::{stdin, stdout, Write};
use std::sync::Arc;
#[derive(Debug, Copy, Clone)]
pub struct MidiPitch {
tag:... | true |
57bd57beb589f3b87538254d28caf220cacb8349 | Rust | ontio/ontology-wasm-cdt-rust | /ontio-std/src/console.rs | UTF-8 | 396 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | mod env {
extern "C" {
pub fn ontio_debug(data: *const u8, len: u32);
}
}
///Used to print the debug information in the contract, which can be seen in the log of the ontology node
/// # Example
/// ```no_run
/// # use ontio_std::console;
/// console::debug("test");
/// ```
pub fn debug(msg: &str) {
... | true |
53e710541ebfe820bded15342c4207b39850d527 | Rust | rikitau/btckey | /src/main.rs | UTF-8 | 2,345 | 2.578125 | 3 | [
"MIT"
] | permissive | // use std::{env, process};
use std::str::FromStr;
use std::io;
// rand crate recommend using ring for secure applications
use ring::rand::{SystemRandom,SecureRandom};
use bip39::Mnemonic;
use miniscript::bitcoin::secp256k1::Secp256k1;
use miniscript::bitcoin::network::constants::Network;
use miniscript::bitcoin::uti... | true |
2389d7d9690aad7f5bf68e4918338ed3193287e7 | Rust | paulocsanz/arraystring | /ffi/src/lib.rs | UTF-8 | 4,527 | 2.53125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use arraystring::{Error, prelude::*, 63};
pub type Str = CacheString;
pub type Len = U63;
#[no_mangle]
pub unsafe extern "C" fn new() -> Str {
Str::new()
}
#[no_mangle]
pub unsafe extern "C" fn try_from_str(s: &str) -> Result<Str, OutOfBounds> {
Str::try_from_str(s)
}
#[no_mangle]
pub unsafe extern "C" fn f... | true |
4c7d1383a61d88010a1a39b096ae00b80a32690c | Rust | boxdot/advent-of-code-2019 | /boxdot/src/day03.rs | UTF-8 | 3,892 | 3.515625 | 4 | [] | no_license | use std::collections::HashMap;
pub fn solve(input: &str) -> Option<(usize, usize)> {
let mut lines = input.lines();
let wire1 = parse(lines.next()?);
let wire2 = parse(lines.next()?);
let grid = build_grid(&wire1, &wire2);
Some((part1(&grid)?, part2(&grid)?))
}
fn parse(s: &str) -> Vec<(Direction... | true |
f8a363c6d51bb44adfe86f9901aefb7ae5b40fc5 | Rust | MWGitHub/terrain | /terrain_math/src/array_2d.rs | UTF-8 | 2,395 | 4.09375 | 4 | [] | no_license | /// Generic Array 2D structure which does not copy data.
pub mod array_2d {
/// Converts coordinates to an index.
/// ```
/// let result = coords_to_index(1, 2, 2)
/// assert_eq!(result, 5)
/// ```
pub fn coords_to_index(x: usize, y: usize, width: usize) -> usize {
x + y * width
}
... | true |
06513ff9d34f0a8ce72569bd43015e1c9f747eba | Rust | r1cebank/rgb | /src/cartridge/mbc1.rs | UTF-8 | 3,449 | 3.328125 | 3 | [
"MIT"
] | permissive | use super::Cartridge;
use crate::memory::Memory;
use crate::save::Savable;
use std::path::PathBuf;
pub struct Mbc1 {
rom: Vec<u8>,
ram: Vec<u8>,
bank: usize,
bank_mode: BankMode,
ram_enabled: bool,
}
#[derive(Copy, Clone, Debug, PartialEq)]
enum BankMode {
Rom,
Ram,
}
/// MBC1 - Memory Ba... | true |
ae6af695ec40e5f598585b20b2d11ee13d8f0633 | Rust | AQUIN0S/rust-sudoku | /src/grid/item/mod.rs | UTF-8 | 5,054 | 3.796875 | 4 | [] | no_license | mod value;
pub use value::Value;
/// Represents a grid item in a sudoku - essentially one square. An item could contain a list of values which the player thinks may be in the square (`Notes`),
/// or may contain a value between 1-9 inclusive (`Number`).
///
/// The `Number` value may be fixed or not - a fixed item rep... | true |
b6839903c2bf428c35d657b54abbc186145164fe | Rust | Claude-Monet/leetcode_solutions | /leetcode_in_rust/src/main.rs | UTF-8 | 4,934 | 2.875 | 3 | [] | no_license | use std::collections::HashMap;
use std::collections::VecDeque;
use std::ops::Deref;
fn main() {
// let v = vec![vec![2,4,3,5], vec![5,4,9,3], vec![3,4,2,11]];
// println!("{}", Solution::max_moves(v));
let v: usize = 0;
println!("{}", Solution::sum_of_power(vec![658,489,777,2418,1893,130,2448,178,1128,... | true |
d59fa967617feda30ef06d4d9e238e1852f9730c | Rust | ZacJoffe/chip8-emulator | /src/graphics.rs | UTF-8 | 2,082 | 3.21875 | 3 | [
"MIT"
] | permissive | use sdl2::pixels::Color;
use sdl2::rect::Rect;
use sdl2::render::WindowCanvas;
pub struct Graphics {
gfx: [[u8; 64]; 32], // represent graphics as a 2d array
draw_flag: bool
}
impl Graphics {
pub fn new() -> Graphics {
Graphics {
gfx: [[0; 64]; 32],
draw_flag: true
... | true |
35c8bb8ef5e95081607c96f43fffe03a3982a34d | Rust | starcoinorg/Coerce-rs | /coerce-remote/src/net/server/session.rs | UTF-8 | 3,142 | 2.515625 | 3 | [] | no_license | use crate::codec::MessageCodec;
use crate::net::codec::NetworkCodec;
use crate::net::message::ClientEvent;
use coerce_rt::actor::context::ActorHandlerContext;
use coerce_rt::actor::message::{Handler, Message};
use coerce_rt::actor::Actor;
use futures::SinkExt;
use std::collections::HashMap;
use tokio_util::codec::Frame... | true |
8d792a65deaf2a07e1cea44b54b592a0437d24f3 | Rust | DwaynesWorld/meshFS | /src/main.rs | UTF-8 | 1,754 | 2.953125 | 3 | [] | no_license | mod command;
mod server;
mod storage;
use clap::{App, Arg, SubCommand};
/// Provides a RESTful web server for managing a distributed file system.
///
/// API spec:
///
/// - `GET v1/blobs/`: returns the key and location of all blobs.
/// - `GET v1/blobs/<key>`: returns a redirect to the volume location of the blob.
/... | true |
31e2cc75a362eb7aa77ded4e4b41ac511387ff56 | Rust | boybird/codewarust | /src/LastDigitOfaHugeNumber.rs | UTF-8 | 1,915 | 3.4375 | 3 | [] | no_license | fn last_digit(list: &[u64]) -> u64 {
if list.len() == 0 {
return 1;
}
if list.len() == 1 {
return list[0] % 10;
}
let pow_0 = check_zero(&list[1..]);
if pow_0 == 0 {
return 1;
}
if pow_0 == 1 {
return list[0];
}
let n = list[0] % 10;
if n == 0 ... | true |
02c2f3f73b764a505e1af4e7c88e8795486b314a | Rust | erikiva/advent-of-code | /2021-rust/src/day15.rs | UTF-8 | 4,630 | 3.3125 | 3 | [] | no_license | use std::cmp::Ordering;
use std::collections::BinaryHeap;
use std::collections::HashMap;
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub struct Risk {
position: (usize, usize),
value: u32,
}
// The priority queue depends on `Ord`.
// Explicitly implement the trait so the queue becomes a min-heap
// instead of a ... | true |
fb8ffa0e6a08c999b7ac927f82bbc89c645b46c3 | Rust | chin0/llrl | /llrl0/src/code/set.rs | UTF-8 | 1,584 | 2.765625 | 3 | [] | permissive | use super::{Code, Error};
use crate::path::{ModuleName, PackageName, Path};
use crate::topological_sort;
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct CodeSet {
map: HashMap<PackageName, HashMap<ModuleName, Code>>,
}
impl CodeSet {
pub fn new() -> Self {
Self {
map: Has... | true |
a519b7129347ee8d4c9e27da05bd78bbcddfb350 | Rust | maffei2443/trabalho-lp1-2018 | /examples/inclusive_for.rs | UTF-8 | 331 | 2.859375 | 3 | [] | no_license | fn main() {
for i in -2..=13 {
match i {
0...5 => println!("{} belongs to 0...5 ", i),
// 5 => println!("i is {}", i),
6..= 9 => println!("{} BELONGS to 6..=9", i),
// -1..100 => println!("out of bounds! i is {}", i),
-1...100 => println!("out of bounds! i is {}", i),
_ => (),
... | true |
eca321076063da384ad99e7cd561016e17ec9db7 | Rust | EFanZh/LeetCode | /src/problem_0399_evaluate_division/bfs.rs | UTF-8 | 3,173 | 3.15625 | 3 | [] | no_license | pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
use std::collections::{HashMap, HashSet, VecDeque};
use std::convert::TryInto;
impl Solution {
fn extract_edge(edge: &[String]) -> (&str, &str) {
let [dividend, di... | true |
604be7397cbdcb7f17603d14e1c3d3d59d7e10de | Rust | rust-lang/rustc-perf | /collector/compile-benchmarks/piston-image/src/png.rs | UTF-8 | 4,899 | 2.953125 | 3 | [
"MIT"
] | permissive |
//! Decoding and Encoding of PNG Images
//!
//! PNG (Portable Network Graphics) is an image format that supports lossless compression.
//!
//! # Related Links
//! * http://www.w3.org/TR/PNG/ - The PNG Specification
//!
extern crate png;
use self::png::HasParameters;
use std::io::{self, Read, Write};
use image::{Im... | true |
c8823cde86c705e2d7cd8b5fa7751d6aee75f6e5 | Rust | newsboat/newsboat | /rust/strprintf/src/traits.rs | UTF-8 | 5,236 | 3.984375 | 4 | [
"MIT",
"CC-BY-4.0"
] | permissive | //! Traits required by `fmt!` macro.
//!
//! `fmt!` needs to convert values from Rust types like `u64` and `String` to C types like
//! `uint64_t` and `const char*`.
//!
//! For integer types, this happens automatically, e.g. `u64` can be passed directly into
//! `libc::snprintf`.
//!
//! Floating-point types are a bit... | true |
82d0981ba54db0e737ddebefb7fce22c071c7b18 | Rust | cloudhead/nakamoto | /net/poll/src/fallible.rs | UTF-8 | 438 | 2.765625 | 3 | [
"MIT"
] | permissive | use std::sync::Mutex;
pub(super) static FALLIBLE: Mutex<Option<f64>> = Mutex::new(None);
pub(crate) struct FailGuard {}
impl Drop for FailGuard {
fn drop(&mut self) {
let mut fallible = self::FALLIBLE.lock().unwrap();
*fallible = None;
}
}
#[allow(dead_code)]
pub(crate) fn set_fallible(p: f6... | true |
2aaf6e85996b624a35ea5010ccd496822766dd82 | Rust | str4d/zebra | /zebra-network/src/protocol/external/message.rs | UTF-8 | 12,368 | 2.765625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Definitions of network messages.
use std::error::Error;
use std::{net, sync::Arc};
use chrono::{DateTime, Utc};
use zebra_chain::block::{Block, BlockHeader, BlockHeaderHash};
use zebra_chain::{transaction::Transaction, types::BlockHeight};
use super::inv::InventoryHash;
use super::types::*;
use crate::meta_addr... | true |
42efc0db0a985cc1b6744b20d429915017426e59 | Rust | rustonaut/media-type-impl-utils | /src/quoted_string/other.rs | UTF-8 | 15,403 | 2.765625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use lut::{Table, Access};
use lookup_tables::{
MediaTypeChars,
QTextWs,
DQuoteOrEscape,
RestrictedToken, VCharWs
};
use qs::error::CoreError;
use qs::spec::{
PartialCodePoint,
ParsingImpl,
State,
WithoutQuotingValidator,
QuotingClassifier, QuotingClass,
};
/// a type providing a "c... | true |
c51fc2c357d29bb0e079f52935f225fcd234a157 | Rust | MostafaAlnasr/idolsched | /src/sim/acc_handle.rs | UTF-8 | 1,546 | 3.421875 | 3 | [] | no_license | // accessory handles.
// these represent either the absense of an accessory, or a 15-bit
// index to an accessory if one is present.
// derived implementations for partialeq, eq, partialord, ord, hash
// rely on the use of 0xffff as the exclusive sentinel value.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, ... | true |
0aa18e2fc47fe8b7dfe53862145f539170ed40c3 | Rust | nic96/avoxel | /crates/avoxel_mesher/src/state.rs | UTF-8 | 1,197 | 2.5625 | 3 | [] | no_license | use avoxel_blocks::BlockLibrary;
use bevy::prelude::*;
#[derive(Eq, PartialEq, Copy, Clone)]
pub enum States {
LoadingMaterials,
Meshing,
}
pub struct State {
active_state: States,
}
impl Default for State {
fn default() -> State {
State {
active_state: States::LoadingMaterials,
... | true |
8fb2bb10c1eb3511273332b9dad95949d6f56552 | Rust | victorminden/orangutan | /src/object/built_in_functions.rs | UTF-8 | 4,470 | 3.5625 | 4 | [] | no_license | //! BuiltInFunctions
//!
//! `built_in_functions` contains the implementation of functions built-in to the Monkey language.
use crate::evaluator::EvalError;
use crate::object::Object;
use num_enum::{IntoPrimitive, TryFromPrimitive};
// TODO: Document.
#[derive(IntoPrimitive, TryFromPrimitive, Debug, Eq, PartialEq, Cl... | true |
390650299553a0329d1598fab553aa7ba25eb66c | Rust | ubnt-intrepid/expected | /src/disappoint.rs | UTF-8 | 2,815 | 3.09375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::{any::Any, fmt};
/// A set of `Disappoint`s occurred during an execution of `expected`.
#[derive(Debug)]
pub struct Disappoints(pub Vec<Disappoint>);
impl std::ops::Deref for Disappoints {
type Target = [Disappoint];
#[inline]
fn deref(&self) -> &Self::Target {
&*self.0
}
}
impl fmt... | true |
d927777db133dac72e664785613dd0f768acc1d3 | Rust | oberblastmeister/monkey | /crates/monkey-lang/src/evaluating/eval/stmt.rs | UTF-8 | 282 | 2.765625 | 3 | [] | no_license | pub use crate::{ast, Eval, EvalResult, Value};
impl Eval for ast::Stmt {
fn eval(self) -> EvalResult<Value> {
match self {
ast::Stmt::Expr(stmt_expr) => stmt_expr.eval(),
_ => todo!("Only expression statements are supported"),
}
}
}
| true |
fe990ee201c824752d54e1220b8c3539c0f0fb46 | Rust | cwmoo740/rust-practice | /src/scheduling.rs | UTF-8 | 1,734 | 3.4375 | 3 | [
"MIT"
] | permissive | pub fn solve(jobs: &Vec<&Job>) -> usize {
if jobs.len() == 0 {
return 0;
}
let mut max_profit = vec![0usize; jobs.len() + 1];
for (i, &job) in jobs.iter().enumerate() {
let profit_prior_jobs = jobs[0..i]
.iter()
.enumerate()
.filter(|&(_, &x)| x.finish... | true |
af56326de566795dfb2d1c40fe861d936b18de04 | Rust | mathiversen/d4t4 | /tests/comments.rs | UTF-8 | 1,306 | 2.703125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | use d4t4::{parse, Result};
use indoc::indoc;
use insta::assert_json_snapshot;
#[test]
fn it_can_parse_object_with_comment() -> Result<()> {
let markup = indoc!(
r#"[
{
/* This is a comment */
"values": "10"
}
]"#
);
let x = parse(marku... | true |
c09fe0128f494f025b9c885d67276989ec4f20ce | Rust | KuabeM/cargo-spellcheck | /src/action/interactive.rs | UTF-8 | 17,073 | 3.03125 | 3 | [] | no_license | //! Interactive picking of replacements, contained in a suggestion.
//!
//! The result of that pick is a bandaid.
use super::*;
use crossterm;
use crossterm::{
cursor,
event::{Event, KeyCode, KeyEvent, KeyModifiers},
style::{style, Attribute, Color, ContentStyle, Print, PrintStyledContent, StyledContent}... | true |
86f823b59dc0d4f3f65da4522f0ae5c1122763a9 | Rust | cbourjau/scraping-dbg | /src/parsing.rs | UTF-8 | 1,947 | 3.359375 | 3 | [] | no_license | use regex::Regex;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ParsingError {
#[error("Field not set: {0}")]
MissingField(&'static str),
#[error("Scraping error")]
ScrapingError(#[from] crate::scrapers::EngineError),
#[error("Network Error")]
IoError(#[from] reqwest::Error),
}
#[... | true |
593558a31d89d7d65f932591617a77125297a208 | Rust | XuShaohua/nc | /src/calls/timerfd_settime.rs | UTF-8 | 1,113 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | /// Set current timer via a file descriptor.
///
/// # Example
///
/// ```
/// let ret = unsafe { nc::timerfd_create(nc::CLOCK_MONOTONIC, nc::TFD_CLOEXEC) };
/// assert!(ret.is_ok());
/// let fd = ret.unwrap();
///
/// let flags = 0;
/// let time = nc::itimerspec_t {
/// it_interval: nc::timespec_t::default(),
/// ... | true |
591f41e016a65d62dcbce3fbd0c32895b3088cb4 | Rust | marco-c/gecko-dev-comments-removed | /third_party/rust/time/src/utc_offset.rs | UTF-8 | 5,895 | 2.703125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
use core::fmt;
use core::ops::Neg;
#[cfg(feature = "formatting")]
use std::io;
use crate::error;
#[cfg(feature = "formatting")]
use crate::formatting::Formattable;
#[cfg(feature = "parsing")]
use crate::parsing::Parsable;
#[cfg(feature = "local-offset")]
use crate::sys::local_offset_at;
#[cfg(feature = "local-offset... | true |
e1e39b6fd97870ede21fa8fd202142f7570b0f9b | Rust | LDA111222/GraphScope | /interactive_engine/src/executor/Pegasus/src/graph/topology.rs | UTF-8 | 12,522 | 2.6875 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"BSL-1.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-elastic-license-2018",
"LicenseRef-scancode-other-permissive"
] | permissive | //
//! Copyright 2020 Alibaba Group Holding Limited.
//!
//! 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 ... | true |
4686ff8c3ccca56abe9f1f2a9e8b242d933be83d | Rust | softdevteam/grmtools | /lrpar/src/lib/mod.rs | UTF-8 | 7,575 | 2.828125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![allow(clippy::cognitive_complexity)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::needless_doctest_main)]
#![allow(clippy::new_without_default)]
#![allow(clippy::range_plus_one)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::type_complexity)]
#![allow(clippy::unnecessary_wraps)]
#![allow(clipp... | true |
f6c887b160207fc39db177138a0c0868505f46fe | Rust | input-output-hk/jormungandr | /modules/blockchain/src/epoch_info.rs | UTF-8 | 3,877 | 2.703125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::block0;
use chain_impl_mockchain::{
block::Block,
header::{BlockDate, Header},
leadership::{self, Leadership, Verification},
ledger::{EpochRewardsInfo, Ledger},
};
use chain_time::{
era::{EpochPosition, EpochSlotOffset},
Epoch, Slot, TimeFrame,
};
use std::time::SystemTime;
use thiser... | true |
875e75ba5368a7ee5d6a373e53869ff68dcea6c8 | Rust | giodamelio/little_boxes | /vendor/rustix/src/io/fcntl.rs | UTF-8 | 5,649 | 3.125 | 3 | [
"MIT",
"Apache-2.0",
"LLVM-exception"
] | permissive | //! The Unix `fcntl` function is effectively lots of different functions
//! hidden behind a single dynamic dispatch interface. In order to provide
//! a type-safe API, rustix makes them all separate functions so that they
//! can have dedicated static type signatures.
//!
//! `fcntl` functions which are not specific t... | true |
0e68ad3b8ffbcca044d07b53513878a23c36da92 | Rust | magurotuna/atcoder-submissions | /dp/src/bin/k.rs | UTF-8 | 649 | 2.640625 | 3 | [] | no_license | use libprocon::*;
fn main() {
input! {
n: usize,
k: usize,
a: [usize; n],
}
// dp[i] := i個の石からなる山のとき、それが必敗パターンであるか否か
let mut dp = vec![None; k + 1];
dp[0] = Some(true);
for i in 1..=k {
if a.iter()
.filter_map(|&x| i.checked_sub(x))
.all... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.