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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ff6ff797395c58b7744d486878d04a9ccef939f0 | Rust | 01intelligence/hulk | /src/object/api_datatypes.rs | UTF-8 | 5,044 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::HashMap;
use crate::utils;
pub enum BackendType {
Unknown,
Fs,
Erasure,
Gateway,
}
pub struct ObjectInfo {
// Name of the bucket.
pub bucket: String,
// Name of the object.
pub name: String,
// Date and time when the object was last modified.
pub mod_time... | true |
ce9b04fee293d340143459d73dc5514601a6abd8 | Rust | IThawk/rust-project | /rust-master/src/test/ui/enum-variant-generic-args.rs | UTF-8 | 2,915 | 3.03125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | #![feature(type_alias_enum_variants)]
enum Enum<T> { TSVariant(T), SVariant { v: T } }
type Alias<T> = Enum<T>;
type AliasFixed = Enum<()>;
impl<T> Enum<T> {
fn ts_variant() {
Self::TSVariant(());
//~^ ERROR mismatched types [E0308]
Self::TSVariant::<()>(());
//~^ ERROR type argume... | true |
ff48a03ab2b812a9b1d74919ec107b30475b73e5 | Rust | gysddn/matrix-rust-sdk | /crates/matrix-sdk/src/encryption/identities/users.rs | UTF-8 | 13,771 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2021 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... | true |
36aa2bcebb5bb3a0cc0da7b582cad2ce7e622b67 | Rust | lsunsi/marskov | /tests/crypto.rs | UTF-8 | 4,303 | 2.65625 | 3 | [] | no_license | extern crate marskov;
use std::sync::Arc;
use std::ops::Deref;
use std::sync::RwLock;
use std::time::Duration;
use std::sync::mpsc::channel;
use std::thread::{sleep, spawn};
use marskov::{Brain, Game};
use marskov::memories::Table;
use marskov::tasks::{play, train, walk};
use marskov::policies::{Greedy, Random};
#[d... | true |
aa68327c58ee5e6178ae2d74af813ab714757e27 | Rust | Ogiwara-CostlierRain464/RustSample | /src/ant/one/ants.rs | UTF-8 | 464 | 3.03125 | 3 | [] | no_license | use std::cmp::{min, max};
/// アリが与えられて、アリが落ちるまでの最小と最大の方向
/// アリの初期の位置はわからない
pub fn ants (l: i32, ants: &[i32]){
let mut min_t = 0;
for &ant_pos in ants{
min_t = max(min_t, min(ant_pos, l - ant_pos));
}
let mut max_t = 0;
for &ant_pos in ants{
max_t = max(max_t, max(ant_pos, l - ant... | true |
576f60b95d910dbdc6791842582fadf523046e45 | Rust | h3nnn4n/smart-panda | /src/gamestate/feature_functions/vertical_roughness.rs | UTF-8 | 2,400 | 3.109375 | 3 | [
"MIT"
] | permissive | #![allow(dead_code)]
use gamestate::board;
use wasm_bindgen::prelude::*;
use gamestate::GameState;
pub fn vertical_roughness(board: &board::Board) -> u32 {
let mut total_vertical_roughness = 0;
for x in 0..board.get_width() {
let mut last_block = board.get_block(x, 0);
if last_block > 127 {... | true |
e0c4397db461420fc11df2be0b0c297f21967f03 | Rust | vindvaki/advent-of-code-2017 | /src/bin/day_11.rs | UTF-8 | 3,884 | 3.25 | 3 | [] | no_license | extern crate aoc2017;
use aoc2017::read_fixture;
use std::ops::{Add, AddAssign, Sub, SubAssign};
extern crate num;
use num::Float;
fn main() {
let data = read_fixture();
let steps: Vec<&str> = data.split(',').map(|s| s.trim()).collect();
println!("part_1: {}", part_1(&steps));
// println!("part_2: {}... | true |
44d68ee1be5b013202d65a3193fa5de3c6d94fc0 | Rust | twetzel59/thread_world_gen | /src/main.rs | UTF-8 | 1,318 | 2.65625 | 3 | [
"Unlicense"
] | permissive | extern crate sfml;
extern crate thread_world_gen;
use sfml::graphics::*;
use sfml::window::{ContextSettings, Event, Key, style};
use thread_world_gen::*;
use worldgen::TERRAIN_SIZE;
fn main() {
let mut win = create_window();
let mut wg = Worldgen::new();
wg.generate_all();
println!("world: {:?}", wg.... | true |
425c52b5780de81dac8e7029dcdf64da373dca62 | Rust | 1keyjee1/smcurser | /src/utilities.rs | UTF-8 | 1,462 | 2.625 | 3 | [] | no_license | use chrono::prelude::*;
use notify_rust::Notification;
use std::{
io::prelude::*,
fs::OpenOptions,
};
use crate::*;
pub struct Utilities;
impl Utilities {
pub fn date_pad_string(date: i64, width: usize) -> String {
let unix_timestamp = (date / 1000000000) + 978307200;
let naive = NaiveDateTime::from_timestamp... | true |
fc32f686993df7b5aa3a26f2cd84aed3193364da | Rust | gazzyt/linkerd2-proxy | /linkerd/timeout/src/idle.rs | UTF-8 | 4,148 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use crate::error::HumanDuration;
use futures::{future, Future, Poll};
use linkerd2_error::Error;
use std::time::{Duration, Instant};
use tokio_timer::Delay;
#[derive(Copy, Clone, Debug)]
pub struct IdleLayer(Duration);
#[derive(Debug)]
pub struct Idle<S> {
inner: S,
idle: Delay,
timeout: Duration,
}
#[de... | true |
986191c88cdfaebaac68e5133bc07675b22a0a78 | Rust | bobbobbio/battleship | /battleship-game/src/client/blocking.rs | UTF-8 | 4,562 | 2.6875 | 3 | [] | no_license | // copyright 2020 Remi Bernotavicius
use super::{ClientResponse, GameClient};
use crate::protocol::Response;
use crate::{
AttackResult, Direction, Error as GameError, GameId, Location, Play, Player, PlayerId,
Result as GameResult, ShipId,
};
use serde::Deserialize;
use std::io;
use std::net::TcpStream;
#[deri... | true |
3556ca5e6373cea51905c67f9d99c597c1d46a71 | Rust | pacak/luhn-rs | /src/lib.rs | UTF-8 | 4,360 | 3.328125 | 3 | [
"MIT"
] | permissive | /*! Validates strings and computes check digits using the Luhn algorithm.
It's not a great checksum, but it's used in a bunch of places (credit
card numbers, ISIN codes, etc.). More information is available on
[wikipedia](https://en.wikipedia.org/wiki/Luhn_algorithm).
*/
/// Validates the given string using the Luhn... | true |
b159f0da22331a13596edaa41fe1e6e393c4bd50 | Rust | igncp/code-gym | /rust/advent_of_code_18/22/src/main.rs | UTF-8 | 19,969 | 3.5625 | 4 | [] | no_license | /*
--- Day 22: Mode Maze ---
This is it, your final stop: the year -483. It's snowing and dark outside; the only light you can
see is coming from a small cottage in the distance. You make your way there and knock on the door.
A portly man with a large, white beard answers the door and invites you inside. For someone... | true |
2fb5b70aafa9b0fc42d3b32d79fb0829c468b06a | Rust | yspace/begin_rust | /src/the_book/functional_lang_features/closures.rs | UTF-8 | 7,725 | 3.296875 | 3 | [
"MIT"
] | permissive |
use std::thread;
use std::time::Duration;
fn simulated_expensive_calculation(intensity: u32) -> u32 {
println!("calculating slowly...");
thread::sleep(Duration::from_secs(2));
intensity
}
fn generate_workout(intensity: u32, random_number: u32) {
if intensity < 25 {
println!(
"Today... | true |
1892612adb9fbb1afd6ff1d78b55e9d3e65bde5e | Rust | Byron/gitoxide | /gix-url/src/expand_path.rs | UTF-8 | 4,431 | 3.34375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Functions for expanding repository paths.
use std::path::{Path, PathBuf};
use bstr::{BStr, BString, ByteSlice};
/// Whether a repository is resolving for the current user, or the given one.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::... | true |
f75618011dcd462d229e5f13a85bc9212acf538b | Rust | clux/tournament-rs | /src/game.rs | UTF-8 | 5,042 | 3.15625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::fmt;
use std::cmp::Ordering;
//use super::TRes;
// TODO: add sanity checks that Seed > 0 from user input
const INVALID: i32 = -1;
const PLACEHOLDER: i32 = 0;
pub type Seed = i32;
pub type Score = u32;
/// A unique representation of a match in the tournament
#[derive(Eq, PartialEq, Ord, PartialOrd, Seriali... | true |
cf54d21002c9b7eb7e4ae183ffd502ac58cce3c5 | Rust | Mange/git-trivia | /src/formatters/json.rs | UTF-8 | 2,968 | 2.859375 | 3 | [] | no_license | extern crate serde;
extern crate serde_json;
use std::collections::BTreeMap;
use self::serde::ser::{Serialize, Serializer, SerializeStruct, SerializeMap};
use person::{CombinedTracking, PeopleTracking, TeamTracking};
use ownership::{OwnershipStatistics, ComputedOwnership};
use errors::*;
// The JSON formatter print... | true |
41598894dcdf588d350e5722f93ee3f3a00d9c13 | Rust | djmitche/rubbish | /src/cas/hash.rs | UTF-8 | 1,685 | 3.609375 | 4 | [] | no_license | use crypto::digest::Digest;
use crypto::sha2::Sha256;
use rustc_serialize::hex::{FromHex, ToHex};
use std::fmt;
/// Type Hash represents the key under which content is stored.
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, RustcDecodable, RustcEncodable)]
pub struct Hash(Vec<u8>);
impl Hash {
/// Create a ... | true |
445b1cbcf79e158db0ff4651bdbc18aee4aeb176 | Rust | MukundhBhushan/rust-tots | /vars/clodeblock.rs | UTF-8 | 255 | 3.703125 | 4 | [] | no_license | fn main(){
let x=10;
//code block
{
//have access to vars outside the block
let y = 20;
println!("x:{},y:{}",x,y);
}
//will throw error as y has no access outside code block
println!("y:{}",y);
} | true |
53fae19145bf7ee8ccf9d874f84702d5525552f3 | Rust | ciz/rust-cryptopals | /src/set2/chals.rs | UTF-8 | 7,811 | 2.90625 | 3 | [] | no_license | extern crate collections;
use utils::cryptodata::{CryptoData};
use utils::utils::{decrypt_and_find_CBC,flip_bits,wrap_and_encrypt_CBC};
use self::collections::vec::Vec;
use std::collections::HashMap;
use std::iter::{range_step,range_inclusive};
// Implement PKCS#7 padding
pub fn chal9() {
let text = CryptoData::from... | true |
57b20721f993b1ee4607b21dc3934b6658eb8379 | Rust | replicante-io/common | /util/rndid/src/lib.rs | UTF-8 | 2,536 | 3.46875 | 3 | [
"MIT"
] | permissive | use std::fmt;
use std::str::FromStr;
use data_encoding::DecodeError;
use data_encoding::DecodeKind;
use data_encoding::HEXLOWER_PERMISSIVE;
use rand::Rng;
use serde_derive::Deserialize;
use serde_derive::Serialize;
/// Randomly generated (probably) unique IDs.
///
/// IDs are generated as a random sequence of 128 bit... | true |
e2e92173c8df23a6ab5d226b37deb1443ad057fe | Rust | wschella/rsrl-types | /examples/example.rs | UTF-8 | 3,473 | 3.125 | 3 | [] | no_license | extern crate rand;
extern crate spaces;
use rand::distributions::{Distribution, Uniform};
use rand::Rng;
use spaces::Space;
extern crate rsrl_types;
use rsrl_types::OnlineLearner;
use rsrl_types::{Action, Controller, Domain, Observation, State, Transition};
fn main() {
let rng = &mut rand::thread_rng();
let... | true |
c86ff3665ebc911fa669a8f5243f1e2f8a576cd5 | Rust | mbStavola/alvin | /src/emulator.rs | UTF-8 | 17,406 | 2.8125 | 3 | [] | no_license | use std::{
collections::VecDeque,
thread,
time::Duration,
};
use rand;
use rand::distributions::{IndependentSample, Range};
use sdl2;
use crate::{
display::Display,
input::{Input, InputAction},
memory::{load_fonts, load_program},
opcode::Opcode,
sound::Sound,
};
pub type Address = u16... | true |
08e5d674604665e1e6af822bcc807a706ea0b82b | Rust | sampersand/sojourn | /sjvm/src/register/debug.rs | UTF-8 | 2,865 | 3.25 | 3 | [] | no_license | use crate::Word;
use super::RegisterTrait;
/// A debug-mode register within [Sojourn's VM](crate::SojournVm).
///
/// # Panics
/// For every function other than [`Register::store`] and [`Register::try_load`], if the
/// contained value is uninitialized, the register will panic.
#[derive(Default, Debug, Clone, Copy, P... | true |
2a87484c7b115e1d42573f76ba5ade54e4e10c5c | Rust | time-rs/time | /time-macros/src/to_tokens.rs | UTF-8 | 1,874 | 2.90625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::num::NonZeroU16;
use proc_macro::{Group, Ident, Literal, Punct, Span, TokenStream, TokenTree};
/// Turn a type into a [`TokenStream`].
pub(crate) trait ToTokenStream: Sized {
fn append_to(self, ts: &mut TokenStream);
}
pub(crate) trait ToTokenTree: Sized {
fn into_token_tree(self) -> TokenTree;
}
i... | true |
2af85fd19093636b378dd9e1b1fcbeab7f9422cc | Rust | TDHolmes/rpi-rgb-led-matrix-rs | /examples/line_spin.rs | UTF-8 | 2,315 | 2.578125 | 3 | [] | no_license | use std::thread::sleep;
use std::time::Duration;
use rgb::RGB8;
use ledmatrix::matrix::{Matrix, LEDMatrixOptions};
use ledmatrix::matrix::HardwareMapping::AdafruitHatPWM;
use ledmatrix::canvas::PixelLocation;
fn main() {
const PANEL_ROWS: i32 = 16;
const PANEL_COLS: i32 = 32;
const NUM_PANELS: i32 = 2;
... | true |
ee03c0b6601d1f2ca13a2c0d3479e7832e60301b | Rust | spencerwi/AdventOfCode2016 | /rust/day5/src/main.rs | UTF-8 | 2,234 | 3.265625 | 3 | [
"MIT"
] | permissive | extern crate crypto;
use crypto::md5::Md5;
use crypto::digest::Digest;
fn starts_with_five_zeroes(hashed: [u8; 16]) -> bool {
// We're dealing with u8, which means 8-bit unsigned ints.
// So each int is a two-digit pair.
// 00 00 0 (we have to shift by 4 bits to get just the... | true |
412b96b31fa445f72a3610cae6d429f84282a0cd | Rust | iinuwa/ruma-client-api | /src/r0/filter.rs | UTF-8 | 8,089 | 2.8125 | 3 | [
"MIT"
] | permissive | //! Endpoints for event filters.
pub mod create_filter;
pub mod get_filter;
use js_int::UInt;
use ruma_identifiers::{RoomId, UserId};
use serde::{Deserialize, Serialize};
/// Format to use for returned events
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum EventForm... | true |
6dd0a6501957023f107b08dbf25a317d7b769003 | Rust | zshipko/worm-rs | /src/client.rs | UTF-8 | 2,573 | 3.0625 | 3 | [
"ISC"
] | permissive | use crate::internal::*;
pub struct Client {
addrs: Vec<std::net::SocketAddr>,
auth: Option<(String, String)>,
pub output: Encoder<tokio::io::WriteHalf<tokio::net::TcpStream>>,
pub input: Decoder<tokio::io::ReadHalf<tokio::net::TcpStream>>,
pub(crate) authenticated: bool,
}
impl Client {
pub(cr... | true |
0d005f0b72d5ded6a5e95fd8f6cf7c128f87a423 | Rust | dalalsunil1986/kwast | /kernel/src/sync/cond_var_single.rs | UTF-8 | 1,663 | 2.984375 | 3 | [
"MIT",
"Apache-2.0",
"BSD-2-Clause"
] | permissive | use crate::mm::tcb_alloc::with_thread;
use crate::sync::spinlock::PreemptCounterInfluence;
use crate::sync::thread_block_guard::ThreadBlockGuard;
use crate::tasking::scheduler::with_current_thread;
use crate::tasking::thread::ThreadId;
use atomic::{Atomic, Ordering};
use spin::MutexGuard;
/// Simple version of a condi... | true |
0e4eb7c7ff37fc3796faf856b99cde8fea188812 | Rust | maciejhirsz/tokio-minihttp | /src/headers.rs | UTF-8 | 1,694 | 3.046875 | 3 | [] | no_license | use smallvec::SmallVec;
use inlinable_string::{InlinableString, StringExt};
use std::slice;
type Header = (InlinableString, InlinableString);
pub struct Headers {
list: SmallVec<[Header; 8]>
}
pub struct ResponseHeadersIter<'res> {
headers: slice::Iter<'res, Header>
}
impl<'res> Iterator for ResponseHeader... | true |
57cc9abbcc9eba6a7ddb97662613ba5541a910f9 | Rust | metajack/rust-css | /select.rs | UTF-8 | 4,692 | 2.71875 | 3 | [] | no_license | /*!
Selector matching
Select matching is performed on generic node types. Client-specific details
about the DOM are encapsulated in the `SelectHandler` type which the `SelectCtx`
uses to query various DOM and UA properties.
*/
use stylesheet::Stylesheet;
use computed::ComputedStyle;
use util::VoidPtrLike;
use wapcapl... | true |
8fe1396d2357daa82222d5d34fc620a7110495ca | Rust | mqnfred/ffishim | /ffishim/src/function.rs | UTF-8 | 2,897 | 2.609375 | 3 | [] | no_license | use crate::types::Behavior;
use crate::helpers::*;
impl ::quote::ToTokens for crate::Function {
fn to_tokens(&self, tokens: &mut ::proc_macro2::TokenStream) {
let ffi_name = &self.ffi_name;
let ffi_args = &self.ffi_args;
let ffi_output = &self.ffi_output;
let call_expr = &self.call_... | true |
24d0f8ddba28c1c7de77fec84816275e7db34eb2 | Rust | hindenbug/pna-rust | /kvs-client-server/src/error.rs | UTF-8 | 1,322 | 2.734375 | 3 | [] | no_license | use failure::Fail;
use std::io;
use std::string;
/// Error type.
#[derive(Fail, Debug)]
pub enum KvsError {
#[fail(display = "{}", _0)]
Io(#[cause] io::Error),
/// Removing non-existent key error.
#[fail(display = "Key not found")]
KeyNotFound,
/// Serialization or deserialization error.
#[... | true |
dfdb71d07ef6217afb061d91caddfe5567b9776a | Rust | jpnykw/nes-emulator | /src/ppu.rs | UTF-8 | 246 | 2.640625 | 3 | [] | no_license | use super::machine;
#[derive(Debug, Copy, Clone)]
pub struct Ppu {
}
impl Ppu {
pub fn new() -> Self {
Self {
}
}
pub fn exec(machine: machine::Machine) {
// レジスタの内容をもとに色の情報などを渡す
}
}
| true |
17a22d509f2865d93e0800c32892821ca6150e84 | Rust | meganetaaan/suburi-rust | /rust-by-example/std-library-types/vectors.rs | UTF-8 | 551 | 3.75 | 4 | [] | no_license | fn main() {
let collected_iterator: Vec<i32> = (0..10).collect();
println!("Collected (0..10) into: {:?}", collected_iterator);
let mut xs = vec![1i32, 2, 3];
println!("Initial vector: {:?}", xs);
println!("Push 4 into vector");
xs.push(4);
println!("Vector: {:?}", xs);
// Immutable v... | true |
aeed7328c5c7d980acd6a148f66cdc56e69b0394 | Rust | kalix-systems/riqtshaw | /src/rust/c_ffi/properties/mod.rs | UTF-8 | 3,745 | 2.828125 | 3 | [] | no_license | use super::*;
mod complex_non_optional;
mod complex_optional;
mod non_complex_non_optional;
mod non_complex_optional;
pub(crate) fn push_properties(scope: &mut Scope, object: &Object) {
for (prop_name, property) in object.properties.iter() {
match &property.property_type {
Type::Object(_) => {... | true |
bf53426edaa466bcee7181d5a5b5ccca96976671 | Rust | u4ium/ray-tracer | /src/scene/object/parsers/obj.rs | UTF-8 | 455 | 2.59375 | 3 | [] | no_license | /// Parse Wavefront .OBJ files
mod polygon;
use self::polygon::Polygon;
mod material;
//use material::Material;
struct Group {
//material: Material,
polygons: Vec<Polygon>,
}
pub struct WaveFrontObject {
name: Option<String>,
groups: Vec<Group>,
}
impl WaveFrontObject {
pub fn to_object(&self) {
... | true |
f97385952f75a7d36a2706aa14deb995e92f2bb8 | Rust | jonnyboyC/cs-Lox | /rsLox/src/scanning/scanning_error.rs | UTF-8 | 551 | 3.078125 | 3 | [
"MIT"
] | permissive | use std::fmt;
use scanning::token_type::TokenType;
#[derive(Debug)]
pub enum ScanningError {
TokenLiteralFound(TokenType),
TokenLiteralNotFound(TokenType)
}
impl fmt::Display for ScanningError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ScanningError::TokenLiteralFound(token_... | true |
8b77906128ad4ba2075139e73b17c2b6b48e9091 | Rust | aerospike/aerospike-client-rust | /tools/benchmark/src/cli.rs | UTF-8 | 5,116 | 2.625 | 3 | [
"LicenseRef-scancode-generic-cla",
"Apache-2.0"
] | permissive | // Copyright 2015-2018 Aerospike, Inc.
//
// Portions may be licensed to Aerospike, Inc. under one or more contributor
// license agreements.
//
// 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 ... | true |
92ec7f9da02f3b6a185b3893e6a94442388d3b9a | Rust | MatchaChoco010/path_tracer_cloth | /src/material.rs | UTF-8 | 2,602 | 3.28125 | 3 | [
"MIT"
] | permissive | #![allow(non_snake_case)]
use nalgebra::Vector3;
/// 三角形のマテリアル。
/// ランバート反射、鏡面反射、透明、発光、布の5種類が実装されている。
pub enum Material {
Lambert {
kd: Vector3<f64>,
},
Mirror {
ks: Vector3<f64>,
},
Glass {
inner_eta: f64,
outer_eta: f64,
},
Emissive {
color: Vector3... | true |
15d1cc236493042ad222b39dc4907339a0df26cf | Rust | suhanyujie/hello_cargo | /src/struct/struct1.rs | UTF-8 | 3,160 | 4.0625 | 4 | [] | no_license | #[derive(Debug)]
struct User {
name:String,
age:i8,
height:i16,
}
fn main(){
let user1 = User {
name:String::from("Samthon"),
age:26,
height:168,
};
//更新部分,其他值使用原先的值,使用语法`..user1`
let user2 = User {
name:String::from("shenshuo"),
age:27,
..use... | true |
816f78a6755bb0c1f6827a36f951de23b2c1bffb | Rust | NickTet/mikack | /src/extractors/manhuapu.rs | UTF-8 | 2,823 | 2.65625 | 3 | [] | no_license | use super::*;
use base64;
use std::str;
def_regex2![
DATA => r#"qTcms_S_m_murl_e="([^"]+)""#
];
/// 对 www.manhuapu.com 内容的抓取实现
def_extractor! {
status => [
usable: true, pageable: false, searchable: true, https: false
],
tags => [Chinese],
fn index(&self, _page: u32) -> Result<Vec<Comic>> {
l... | true |
b42b884b23a48602b425b64928493d4d075eac82 | Rust | ZapAnton/toy_tracer | /src/main.rs | UTF-8 | 2,843 | 2.75 | 3 | [] | no_license | use std::{
borrow::Borrow,
fs::File,
io::{self, BufWriter, Write},
};
use toy_tracer::{camera::Camera, gvec::Gvec, ray::Ray, sphere::Sphere, Hitable};
use rand::{self, Rng};
const OUTPUT_FILE_PATH: &str = "out/test.ppm";
const NX: i32 = 200;
const NY: i32 = 100;
const NS: i32 = 100;
fn color<T: Hitable... | true |
b8c3bc8239961c158801dcefad6b8da9fe1565ec | Rust | princesinha19/arweaver | /src/client.rs | UTF-8 | 1,896 | 2.765625 | 3 | [
"Unlicense"
] | permissive | use reqwest::Url;
use crate::types::*;
use crate::error::*;
pub struct Client {
url: Url,
}
impl Client {
pub fn new() -> Result<Client, Error> {
let url = Url::parse(&std::env::var("ARWEAVE_TARGET")
.unwrap_or("https://arweave.net".to_string()))?;
Ok(Client { url... | true |
09bf419d89f5a5a5c123baa0c92f0e4c0a39ffa2 | Rust | shadedesignz/rust_roguelike | /src/item.rs | UTF-8 | 8,281 | 2.96875 | 3 | [] | no_license | use crate::ai::Ai;
use crate::equipment::get_equipped_in_slot;
use crate::game::Game;
use crate::map::PLAYER;
use crate::object::*;
use crate::Tcod;
use serde::{Deserialize, Serialize};
use tcod::colors::*;
const HEAL_AMOUNT: i32 = 40;
const LIGHTNING_DAMAGE: i32 = 40;
const LIGHTNING_RANGE: i32 = 5;
const CONFUSE_R... | true |
fa0723a9e4200fa2868c28befa9a594476aa88a6 | Rust | emilio/heapsize | /plugin/tests/tests.rs | UTF-8 | 1,090 | 2.671875 | 3 | [] | no_license | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(plugin, custom_derive)]
#![plugin(heapsize_plugin)]
extern crate heapsize;
use heapsize::HeapSizeOf;
... | true |
ec00fc4af0a0a53ce86c22315bd4db7a8a5b25c1 | Rust | fotonick/doxie-control | /src/main.rs | UTF-8 | 3,930 | 2.78125 | 3 | [
"MIT"
] | permissive | mod discover;
mod doxie;
use std::process::exit;
use clap::{app_from_crate, crate_name, crate_authors, crate_description, crate_version, Arg, SubCommand};
use failure::Error;
use log::info;
use simplelog::{
Config,
LevelFilter,
TermLogger,
};
fn main() -> Result<(), Error> {
let matches = app_from_cr... | true |
4fb6fa9ef8831cd89ac8a705e160ff1f8360f0b5 | Rust | Zombieliu/homework6 | /pallets/kitties/src/tests.rs | UTF-8 | 4,437 | 2.796875 | 3 | [
"Unlicense"
] | permissive | use crate::{Event, Error, mock::*};
use frame_support::{assert_noop, assert_ok, traits::{OnFinalize, OnInitialize}};
fn run_to_block( n: u64) {
while System::block_number() < n {
KittiesModule::on_finalize(System::block_number());
System::on_finalize(System::block_number());
System::set_block_number(System::blo... | true |
41e42b2d0fa0b9b94fc610472c38dc30581c9e13 | Rust | Hyde46/reddit-view-portal | /src/oauth.rs | UTF-8 | 10,678 | 2.6875 | 3 | [] | no_license | extern crate rand;
//Concurrency stuff
use std::io::Read;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
use tiny_http::{Response, Server};
use serde::{Deserialize, Serialize};
use curl::easy::{Easy, List};
#[derive(Debug)]
enum OAuthState {
IDLE,
AUTHORIZED,
ERROR,
}
#[derive(Serialize... | true |
3c0c8f582bdea34d29b89834950ff4d240542ca7 | Rust | FyroxEngine/Fyrox | /editor/src/build.rs | UTF-8 | 6,045 | 2.578125 | 3 | [
"MIT"
] | permissive | use crate::message::MessageSender;
use crate::Message;
use fyrox::{
core::{parking_lot::Mutex, pool::Handle},
gui::{
border::BorderBuilder,
button::{ButtonBuilder, ButtonMessage},
grid::{Column, GridBuilder, Row},
message::{MessageDirection, UiMessage},
scroll_viewer::Scr... | true |
ced247fd39bb5e6ec09e372327a225892051b7ab | Rust | zsytssk/test | /rust/copy_file/src/calc_pool.rs | UTF-8 | 718 | 3.234375 | 3 | [] | no_license | use std::thread;
pub struct CalcPool<T>
where
T: Fn() + Send,
{
items: Vec<Box<T>>,
num: u32,
}
impl<T> CalcPool<T>
where
T: Fn() + Send,
{
pub fn new() -> CalcPool<T> {
CalcPool {
items: vec![],
num: 0,
}
}
pub fn add(&mut self... | true |
51cf142864353818485dfeda4c97d60ea7a189ee | Rust | Dzejkop/kombucha-tracker | /frontend/src/components/error_view.rs | UTF-8 | 1,335 | 2.84375 | 3 | [] | no_license | use yew::prelude::*;
pub struct ErrorView {
link: ComponentLink<Self>,
props: Props,
}
#[derive(Clone, Properties)]
pub struct Props {
#[prop_or("Something went wrong :(".to_string())]
pub msg: String,
#[prop_or_default]
pub on_close: Callback<()>,
}
impl Component for ErrorView {
type Me... | true |
bc87a19673af04868cf822abc6e8095129dbd1e0 | Rust | MuLinjiu/Ray_Tracer | /raytracer/src/materia.rs | UTF-8 | 9,241 | 2.6875 | 3 | [
"MIT"
] | permissive | use std::f64::consts::PI;
use std::sync::Arc;
use crate::hittable::HitRecord;
use crate::onb::Onb;
use crate::pdf::{CosinePdf, NonePdf, Pdf};
use crate::ray::Ray;
use crate::rtweekend::random_double;
use crate::texture::{SolidColor, Texture};
use crate::vec3::{random_in_unit_sphere, reflect, refract, Vec3};
pub fn ra... | true |
289835443bdabfae1da9fba646e173a29b34f527 | Rust | mwarning/MeshNetSimulator | /src/locations.rs | UTF-8 | 1,870 | 3.078125 | 3 | [
"BSD-3-Clause"
] | permissive | use std::collections::HashMap;
use crate::graph::ID;
pub struct Locations {
pub data: HashMap<ID, [f32; 3]>
}
impl Locations {
pub fn new() -> Self {
Self { data: HashMap::new() }
}
pub fn is_valid(pos: &[f32; 3]) -> bool {
!pos[0].is_nan() && pos[1].is_nan() && !pos[3].is_nan()
}
pub fn pos_distance(&se... | true |
a6fcee52b4f9c273f6f5a24730e1a207610ada2e | Rust | MattiaPrimavera/esgi-rust | /src/ch3/parallel-cat.rs | UTF-8 | 438 | 3.109375 | 3 | [
"MIT"
] | permissive | // Parallel cat
use std::thread;
fn main() {
let mut children = vec![];
let args: Vec<String> = std::env::args().collect();
for arg in &args[1..] {
let filename = arg.clone();
children.push(thread::spawn(move || {
std::fs::read_to_string(filename).expect("Something went wrong r... | true |
ab2880e5173bf88fdf7c46be0c450b4093926a86 | Rust | Alexendoo/Advent-of-Code-2020 | /day-15/src/main.rs | UTF-8 | 790 | 3.171875 | 3 | [] | no_license | use std::collections::HashMap;
fn solve(n: usize) -> u32 {
let input = [0, 8, 15, 2, 12, 1, 4];
let mut spoken: HashMap<u32, (u32, Option<u32>)> = input[..input.len() - 1]
.iter()
.enumerate()
.map(|(turn, &n)| (n, (turn as u32, None)))
.collect();
let mut last = *input.last... | true |
df6d08b38ac0bbd8d053e4a5396047a90faabd45 | Rust | afrase/lib-ruby-parser | /gen/nodes/visitor.rs | UTF-8 | 5,993 | 2.9375 | 3 | [
"MIT"
] | permissive | use lib_ruby_parser_nodes::{Field, FieldType, Node};
pub(crate) struct Visitor<'a> {
nodes: &'a [Node],
}
impl<'a> Visitor<'a> {
pub(crate) fn new(nodes: &'a [Node]) -> Self {
Self { nodes }
}
pub(crate) fn write(&self) {
std::fs::write("src/traverse/visitor/visit_gen.rs", self.conten... | true |
2e380494efb3e02bb4c0936b1e4e7ce8f02ba96b | Rust | greysome/grav | /src/body.rs | UTF-8 | 753 | 2.984375 | 3 | [] | no_license | use ggez::nalgebra::{Point2, Vector2};
// All points/vectors are in reference to global xy-plane
// For convenience, 1 unit = 1 metre
#[derive(Debug, Clone, Copy)]
pub struct Body {
pub mass: f32,
pub pos: Point2<f32>,
pub v: Vector2<f32>,
pub a: Vector2<f32>,
pub color: [f32; 4]
}
impl Body {
... | true |
1627de2b7a6a7b876c2dbf0504f31722b7daf5d9 | Rust | maroider/gltf_explorer | /src/explorer/widgets/canvas_background.rs | UTF-8 | 3,844 | 2.765625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use iced_graphics::{
widget::canvas::{Canvas, Program},
Renderer,
};
use iced_native::{
layout::{self, Layout, Node},
overlay::{self, Overlay},
widget::Widget,
Clipboard, Element, Event, Hasher, Length, Point, Size,
};
pub struct CanvasBackground<'a, Message, Renderer, P>
where
Renderer: ic... | true |
64ad6fc5796a3e33b4e1ddea5aca389fd4129089 | Rust | Emerentius/ProjectEuler | /p125_palindromic_sums/src/main.rs | UTF-8 | 903 | 3.109375 | 3 | [] | no_license | #![feature(test)]
extern crate test;
fn is_palindrome(num: u64) -> bool {
let mut num_tmp = num;
let mut reversed = 0;
while num_tmp != 0 {
reversed = reversed*10 + num_tmp % 10;
num_tmp /= 10;
}
reversed == num
}
fn main() {
let squares : Vec<_> = (1..10000).map(|n| n*n).colle... | true |
84712f9eecf3b2a3302a8930670ee64324c53fc1 | Rust | goccmack/gogll | /examples/empty/rust/empty/src/token/mod.rs | UTF-8 | 3,298 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive |
//! Module token is generated by GoGLL. Do not edit
extern crate lazy_static;
use std::rc::Rc;
use std::fmt;
use lazy_static::lazy_static;
use std::collections::HashMap;
/// Token is returned by the lexer for every scanned lexical token
pub struct Token {
pub typ: Type,
pub lext: usize,
pub rext: usize,
inpu... | true |
09be9bad45748e0b8500cb94e41a90a8dfd81fb3 | Rust | sisaphilip/safaricom-alarms | /src/sfcalm3.rs | UTF-8 | 343 | 2.609375 | 3 | [] | no_license | use std::error::Error;
use rppal::gpio::Gpio;
use std::string::String;
const GPIO_SENSOR: u8 =27;
pub fn alm3 () -> Result<(), Box<dyn Error>>
{
let alm_message3 = String::from ("Gen running");
let pin = Gpio::new()?.get(GPIO_SENSOR)?.into_input();
loop{
if pin.is_low() == true {
println!("{}",alm... | true |
767a23a9181db694580daa5b5fc6bdcd473223c9 | Rust | Wilfred/hhvm | /hphp/hack/src/rupro/lib/shallow_decl_provider/provider.rs | UTF-8 | 4,298 | 2.6875 | 3 | [
"PHP-3.01",
"MIT",
"Zend-2.0"
] | permissive | // Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use super::ShallowDeclCache;
use crate::decl_defs::{DeclTy, ShallowClass};
use crate::decl_parser::DeclParser;
use crate::reason::Reason... | true |
659a0924906aa03e6721b5a295f2176938efa043 | Rust | oko/rust-dns | /src/iana/rcodes.rs | UTF-8 | 4,092 | 3.203125 | 3 | [
"BSD-2-Clause"
] | permissive | pub use super::IdentifierError;
#[repr(u16)]
#[derive(PartialEq,Debug,Clone)]
pub enum RCode {
NoError = 0,
FormErr = 1,
ServFail = 2,
NXDomain = 3,
NotImp = 4,
Refused = 5,
YXDomain = 6,
YXRRSet = 7,
NXRRSet = 8,
NotAuth = 9,
NotZone = 10,
BADVERS = 16,
BADKEY = 17,... | true |
a6ad619b690f51eb0eb3d7905dcc393216068192 | Rust | mendelt/sqlx-examples | /examples/map.rs | UTF-8 | 602 | 2.75 | 3 | [] | no_license | use sqlx::prelude::*;
use sqlx::{query_as, PgPool};
const DB_URI: &str = "postgresql://example-user:password123@localhost:5432/example-database";
#[async_std::main]
async fn main() -> Result<(), sqlx::Error> {
let pool = connect_db(DB_URI).await;
let stuff = query_as::<_, Stuff>("SELECT id, name, value FROM ... | true |
332c4c6a0e1a76401d4b5dc25f86a47855792048 | Rust | hjr3/hal-rs | /tests/lib.rs | UTF-8 | 8,283 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | extern crate hal;
extern crate rustc_serialize as serialize;
use hal::ToHal;
use hal::resource::Resource;
use hal::link::Link;
use hal::state::ToHalState;
use hal::state::HalState::{I64, Null};
use serialize::json::Json;
use serialize::json::ToJson;
use std::collections::{HashMap, BTreeMap};
struct Order {
total:... | true |
49d563dfb2df11cd09dd70ea4b97f78c843d7982 | Rust | kryptan/lithium | /lithium_core/src/id.rs | UTF-8 | 965 | 2.9375 | 3 | [] | no_license | use rand::{thread_rng, Rng};
use {Rect, Var};
#[derive(Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd, Debug)]
pub struct Id(u64, u64);
impl Id {
/// Generate new unique id.
pub fn unique() -> Self {
Id(thread_rng().next_u64(), thread_rng().next_u64())
}
}
impl From<Id> for Rect<Var> {
fn ... | true |
636cafd5afd70a013301dd1adf3561e422852164 | Rust | sergey-v-galtsev/xv6-riscv-rust | /src/fs/mod.rs | UTF-8 | 3,120 | 2.53125 | 3 | [
"MIT"
] | permissive | use core::cell::Cell;
use core::option::Option;
use core::ptr;
mod bio;
mod dir;
mod inode;
pub use bio::binit;
use bio::{bread, brelse};
use inode::iget;
// LTODO - just put all the consts relevant to fs to here tmp
pub const BSIZE: usize = 1024;
const NINODE: usize = 50;
const NDIRECT: usize = 12;
const DIRSIZ: u... | true |
6d131aaea9237c1d723d79186fff43ae06f18cdf | Rust | sfikas/xray | /xray_core/src/buffer.rs | UTF-8 | 18,541 | 2.765625 | 3 | [
"MIT"
] | permissive | use std::cmp;
use std::collections::HashSet;
use std::iter;
use std::ops::{Add, AddAssign, Range};
use std::sync::Arc;
use super::tree::{self, Tree};
use notify_cell::NotifyCell;
pub type ReplicaId = usize;
type LocalTimestamp = usize;
type LamportTimestamp = usize;
#[derive(Debug)]
pub struct Buffer {
replica_id... | true |
4ecf0f3560af789e0cdfc96d4aab4578f5168263 | Rust | benjsto/aoc | /2019/2.rs | UTF-8 | 4,794 | 3.5 | 4 | [] | no_license | use std::io;
struct Instruction {
code: i32,
input1_idx: usize,
input2_idx: usize,
output_idx: usize,
}
fn get_program_from_string(string:String) -> Vec<i32> {
let mut program:Vec<i32> = vec![];
for token in string.split(","){
program.push(token.parse::<i32>().unwrap())
}
re... | true |
1022df6d1c72935c6a3ff4a594a2e4c744da8f9a | Rust | codyben/syntax | /src/parser.rs | UTF-8 | 34,022 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | // # Parser
// ## Prelude
use lexer::Token;
use mech_core::{Hasher, Function};
#[cfg(not(feature = "no-std"))] use core::fmt;
#[cfg(feature = "no-std")] use alloc::fmt;
#[cfg(feature = "no-std")] use alloc::string::String;
#[cfg(feature = "no-std")] use alloc::vec::Vec;
use nom::alpha1 as nom_alpha1;
use nom::digit1 ... | true |
bce84432bda57ffe6bebd21c0e8b661014fb241c | Rust | lilianmoraru/rust-tuf | /src/rsa/mod.rs | UTF-8 | 6,486 | 2.921875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Helper module for RSA key encoding / decoding.
mod der;
use untrusted::Input;
use self::der::{Tag, Der};
/// Corresponds to `1.2.840.113549.1.1.1 rsaEncryption(PKCS #1)`
const RSA_PKCS1_OID: &'static [u8] = &[0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01];
pub fn convert_to_pkcs1<'a>(input: &[u8]) -> Ve... | true |
77d91294026ae7d7f51f2c949304b7307cce9338 | Rust | w93163red/w3c-live-data | /src/draw.rs | UTF-8 | 3,887 | 2.65625 | 3 | [] | no_license | use crate::data::fetch::{Data, User};
use std::io;
use tui::layout::{Alignment, Constraint, Direction, Layout};
use tui::style::Color;
use tui::widgets::{Block, Borders, Paragraph, Wrap, Table, Row, TableState};
use tui::{backend::CrosstermBackend, style::Style};
use tui::{text::Text, Terminal};
use crate::util::Format... | true |
509e4edddeb3905021642dd94b665cbc66f0df19 | Rust | Wandalen/bevy-pong-clone | /src/ball.rs | UTF-8 | 2,524 | 2.6875 | 3 | [] | no_license | use crate::{Collider, Reset};
use bevy::app::EventReader;
use bevy::core::Time;
use bevy::ecs::system::{Commands, Query, Res};
use bevy::math::{Vec2, Vec3};
use bevy::prelude::Windows;
use bevy::sprite::collide_aabb::collide;
use bevy::sprite::collide_aabb::Collision;
use bevy::sprite::entity::SpriteBundle;
use bevy::s... | true |
275ecff5b152f68eb0ca9f80c705277ecb91c429 | Rust | svmnotn/upgraded-pancake | /lib/src/table.rs | UTF-8 | 4,594 | 3.0625 | 3 | [
"MIT"
] | permissive | mod table_result;
pub use self::table_result::TableResult;
#[cfg(test)]
mod tests;
use core::{fmt, slice::Iter};
use crate::{Column, Dice, Result, Rows, Row};
use serde::de::{self, Deserialize, Deserializer, MapAccess, SeqAccess, Visitor};
use serde_derive::{Deserialize, Serialize};
/// A `Table` that can be rolled ... | true |
2840a4d8d1cae32e3cf8db2991fba9b5e240009e | Rust | EmbarkStudios/raw-window-handle | /src/windows.rs | UTF-8 | 970 | 2.9375 | 3 | [
"MIT"
] | permissive | use core::ptr;
use libc::c_void;
/// Raw window handle for Windows.
///
/// ## Construction
/// ```
/// # use raw_window_handle::windows::WindowsHandle;
/// let handle = WindowsHandle {
/// /* fields */
/// ..WindowsHandle::empty()
/// };
/// ```
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct WindowsH... | true |
d6e4db84cb0f3053503a837fd216ce78dce50c46 | Rust | 66Origin/nitox | /src/protocol/client/sub_cmd.rs | UTF-8 | 3,614 | 3.53125 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | use bytes::Bytes;
use protocol::{Command, CommandError};
use rand::{distributions::Alphanumeric, thread_rng, Rng};
/// SUB initiates a subscription to a subject, optionally joining a distributed queue group.
#[derive(Debug, Clone, PartialEq, Builder)]
#[builder(build_fn(validate = "Self::validate"))]
pub struct SubCom... | true |
529ab589be71cf4b1f9e80e22355eb5e91d2393e | Rust | JoelWilloughby/adventofcode_2020 | /src/aoc_13.rs | UTF-8 | 4,388 | 3.609375 | 4 | [] | no_license | pub fn do_it(target: usize, nums: &Vec<usize>) -> (usize, usize) {
let mut min_train_id = 0;
let mut min_train_time = usize::MAX;
for &x in nums.iter() {
if x - (target % x) < min_train_time {
min_train_time = x - (target % x);
min_train_id = x;
}
}
(target ... | true |
04b35691e3a0ae9bd1e6a884d6de5250732ae125 | Rust | Dajamante/avr-car | /src/sensor.rs | UTF-8 | 2,479 | 3.15625 | 3 | [] | no_license |
//! ### The sensor Module
//! The sensor module takes a SensorUnit value struct with a trigger, an echo
//! and a timer. As per HC-SR04 documentation, the trigger needs to be up 10 μs
use arduino_uno::prelude::*;
use arduino_uno::hal::port::mode::{Floating};
const TRIGGER_UP_TIME: u16 = 10u16;
/// struct sensor_uni... | true |
3f320cded57dce2cdad74281f8b5cfdd1198c982 | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/k2pc-easy/src/bin/b.rs | UTF-8 | 730 | 2.578125 | 3 | [] | no_license | use proconio::{input, marker::Chars};
fn main() {
input! {
n: usize,
mut a: [usize; 10],
c: [Chars; n],
};
let mut xs = vec![0; 7];
let mut cs = vec![0; 7];
for c_i in c.iter() {
for (j, c_ij) in c_i.iter().copied().enumerate() {
match c_ij {
... | true |
1c3375f4e22c29f50666a46dcc7d600db8ab0d6c | Rust | ngoldbaum/aoc_2019 | /day20/src/main.rs | UTF-8 | 1,515 | 3.140625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
fn main() {
println!("Hello, world!");
}
#[derive(Debug)]
struct Map<'a> {
tiles: HashMap<CoordOrName, MapTile<'a>>,
}
#[derive(Debug, PartialEq, Eq, Hash)]
struct CoordOrName {
coord: Option<(i64, i64)>,
name: Option<String>,
}
impl Map<'_> {
fn from_map_str(map_s... | true |
eab86d73c011f155778de64eb159f8017605ba2c | Rust | iCodeIN/lfu-cache | /src/lib.rs | UTF-8 | 7,665 | 3.59375 | 4 | [] | no_license | //! An efficient [Least Frequently Used Cache](https://en.wikipedia.org/wiki/Least_frequently_used) implementation.
//!
//! It supports insertions and retrievals, both of which are performed in constant time. In the event of tie between
//! two least frequently used entries, the least *recently* used entry is evicted.
... | true |
18384b6729614c849e19c01058907aa482643d32 | Rust | muuuuuua/kv-temp | /src/memtable.rs | UTF-8 | 655 | 3.546875 | 4 | [] | no_license | use std::collections::HashMap;
pub enum ValueType {
TypeDeletion = 0,
TypeValue = 1
}
pub struct MemTable {
table: HashMap<String, (ValueType, String)>,
}
impl MemTable {
pub fn new() -> Self {
MemTable { table: Default::default() }
}
pub fn set(&mut self, value_type: ValueType, key:... | true |
3b3459171103584b0e6834ed395ff82f9ece0f08 | Rust | willtrnr/saprfc-rs | /saprfc/src/connection.rs | UTF-8 | 4,092 | 2.828125 | 3 | [
"MIT"
] | permissive | use crate::{
error::{Result, RfcErrorInfo},
function::RfcFunction,
macros::{check_rc_ok, is_rc_err},
uc,
};
use sapnwrfc_sys::{
self, RfcCloseConnection, RfcCreateFunction, RfcGetFunctionDesc, RfcOpenConnection, RfcPing,
SAP_UC,
};
use std::{collections::HashMap, ptr};
/// An SAP NW RFC connect... | true |
9b353e0b87dc1b6697c0524a562ab82e509e1595 | Rust | jkelleyrtp/onshape-rs | /src/apis/mod.rs | UTF-8 | 2,341 | 2.625 | 3 | [] | no_license | use hyper;
use serde;
use serde_json;
#[derive(Debug)]
pub enum Error<T> {
UriError(hyper::error::UriError),
Hyper(hyper::Error),
Serde(serde_json::Error),
ApiError(ApiError<T>),
}
#[derive(Debug)]
pub struct ApiError<T> {
pub code: hyper::StatusCode,
pub content: Option<T>,
}
impl<'de, T> Fr... | true |
38191403adc5395ddeac6a7dc9bb08b9d0d948fc | Rust | sybila/biodivine-lib-std | /src/lib.rs | UTF-8 | 1,080 | 2.890625 | 3 | [
"MIT"
] | permissive | use std::hash::Hash;
// New stuff - planned for 0.1.0 release
pub mod collections;
pub mod graph;
pub mod logic;
// Old stuff (do not delete until release because people are using it!)
pub mod param_graph;
pub mod util; // not stabilised yet
mod impl_id_state;
mod impl_id_state_range;
/// A marker trait for anythin... | true |
1dfb9a289e128c6109f410c1ae09ee00c2ebec69 | Rust | secti6n/nebulet | /src/object/mono_copy.rs | UTF-8 | 1,030 | 2.984375 | 3 | [
"MIT"
] | permissive | use object::ProcessRef;
use nil::{Ref, KernelRef};
use nabi::{Result, Error};
#[derive(KernelRef)]
pub struct MonoCopyRef {
/// The process that contains the buffer.
process: Ref<ProcessRef>,
buffer: (u32, u32),
}
impl MonoCopyRef {
pub fn new(process: Ref<ProcessRef>, buffer: (u32, u32)) -> Result<Re... | true |
472f542a1b753f561247c71f224565dd15de9d28 | Rust | joshuaclayton/game-curve-probabilities | /src/rolled_dice.rs | UTF-8 | 2,441 | 3 | 3 | [
"MIT"
] | permissive | use super::probabilities;
use super::{DiceProbabilities, Die};
use rand::distributions::Uniform;
use rand::prelude::*;
use rayon::prelude::*;
use std::default::Default;
pub struct RollOutcome {
pub rolls: Vec<(Die, usize)>,
}
impl RollOutcome {
pub fn total(&self) -> usize {
self.rolls.iter().map(|v| ... | true |
719779d14bde6ef46669b908718e999bcb98b4fd | Rust | ioncodes/plasma_loop | /src/main.rs | UTF-8 | 2,073 | 3.015625 | 3 | [
"MIT"
] | permissive | extern crate minifb;
use minifb::{InputCallback, Window, Key, Scale, WindowOptions};
use std::{thread, time};
use std::f32;
const WIDTH: usize = 640;
const HEIGHT: usize = 360;
const SPEED: usize = 2000;
const RING_DENSITY: u32 = 1; // 1 for none
struct KeyCharCallback;
impl InputCallback for KeyCharCallback {
... | true |
d2d83bd56eaec6d69543095cac54bbc34704d8f9 | Rust | aaronleopold/adta | /src-tauri/src/db/mod.rs | UTF-8 | 2,638 | 2.921875 | 3 | [
"MIT"
] | permissive | pub mod entities;
extern crate dirs;
use std::path::PathBuf;
use super::utils::date;
use anyhow::Result;
use entities::todo;
use sea_orm::{
sea_query::SqliteQueryBuilder, ConnectionTrait, Database, DatabaseBackend, DatabaseConnection,
EntityTrait, Schema, Set, Statement,
};
async fn create_default_todos(connec... | true |
7c0dd8c5bcfa37dd494b7ed9ec1956497b86f87f | Rust | vain0x/languages | /picomet-lang/compiler/src/semantics/symbol.rs | UTF-8 | 1,310 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use super::*;
#[derive(Clone, Copy, PartialEq, Debug)]
pub(crate) enum SymbolKind {
Prim(Prim),
Var(VarId),
}
#[derive(Clone, Copy, Debug)]
pub(crate) enum SymbolRef<'a> {
Prim(Prim),
Var(VarId, &'a VarDef),
}
impl SymbolKind {
pub fn is_var(&self) -> bool {
match self {
Symbo... | true |
10bc69ae933a9f3beeeefcdd2c7fe0d2722c375d | Rust | EduRenesto/raytracer | /src/tracer/shape/plane.rs | UTF-8 | 1,168 | 2.96875 | 3 | [] | no_license | use vek::vec::Vec3;
use crate::tracer::material::Material;
use crate::tracer::ray::{Ray, RayHit};
use super::Shape;
#[derive(Copy, Clone)]
pub struct Plane {
pub point: Vec3<f32>,
pub normal: Vec3<f32>,
pub material: Material,
}
impl Plane {
pub fn new(point: Vec3<f32>, normal: Vec3<f32>, material: ... | true |
4a7f4a0ccdd64d60da5bd047b7078da441fb0135 | Rust | hw0lff/tab-rs | /tab-command/src/service/tab/workspace/repo.rs | UTF-8 | 1,204 | 2.734375 | 3 | [
"MIT"
] | permissive | use std::path::Path;
use log::info;
use tab_api::tab::normalize_name;
use crate::state::workspace::{Repo, WorkspaceTab};
use super::loader::WorkspaceBuilder;
pub fn build_repo(builder: &mut WorkspaceBuilder, path: &Path, repo: Repo) {
if builder.contains_repo(path) {
return;
}
info!("Processing... | true |
7efce8e4579baca5f4e48707892ca1f5c65ebd10 | Rust | ntex-rs/ntex | /ntex-tls/examples/simple-client.rs | UTF-8 | 1,321 | 2.5625 | 3 | [
"MIT"
] | permissive | use std::io;
use ntex::{codec, connect, util::Bytes, util::Either};
use tls_openssl::ssl::{self, SslFiletype, SslMethod, SslVerifyMode};
#[ntex::main]
async fn main() -> io::Result<()> {
std::env::set_var("RUST_LOG", "trace");
env_logger::init();
println!("Connecting to openssl server: 127.0.0.1:8443");
... | true |
fb72b3ed1a540e896975962bcd50c7f89982ece4 | Rust | westonkelliher/Setup-Files | /2023-bin/.nub/rusty_nub/src/main.rs | UTF-8 | 686 | 3.125 | 3 | [] | no_license | use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
fn main() -> std::io::Result<()>{
let args: Vec<String> = env::args().collect();
assert_eq!(args.len(), 3);
let mut file = File::create("foo.txt")?;
file.write(args[1].as_bytes())?;
file.write(b"\n")?;
file.write(... | true |
d5885cb32aab09ddf4a4198e9d2457a7c2dc835f | Rust | winksaville/fuchsia | /third_party/rust_crates/vendor/autocfg/src/tests.rs | UTF-8 | 1,747 | 2.765625 | 3 | [
"BSD-3-Clause",
"MIT",
"Apache-2.0"
] | permissive | use super::AutoCfg;
#[test]
fn autocfg_version() {
let ac = AutoCfg::with_dir("target").unwrap();
println!("version: {:?}", ac.rustc_version);
assert!(ac.probe_rustc_version(1, 0));
}
#[test]
fn version_cmp() {
use super::version::Version;
let v123 = Version::new(1, 2, 3);
assert!(Version::ne... | true |
d1ae0c8bd98c79998062fcfa1913f7c598c89a93 | Rust | martinsvalin/advent_of_code | /2022/rust/src/rock_paper_scissors.rs | UTF-8 | 2,740 | 3.484375 | 3 | [] | no_license | use core::cmp::Ordering;
#[derive(Clone, Copy, PartialEq)]
enum RockPaperScissors {
Rock,
Paper,
Scissors,
}
struct Game {
opponent: RockPaperScissors,
me: RockPaperScissors,
}
impl PartialOrd for RockPaperScissors {
fn partial_cmp(self: &Self, rhs: &Self) -> Option<Ordering> {
use Or... | true |
7874f9b1b7b710c9808fdacd761d5824836b16c5 | Rust | jacksonriley/cress | /src/engine/search.rs | UTF-8 | 1,455 | 2.953125 | 3 | [] | no_license | use super::structs::ChessState;
use crate::engine::evaluate::Evaluate;
use std::cmp;
pub fn minimax(
state: &ChessState,
depth: u8,
maximise: bool,
mut alpha: i32,
mut beta: i32,
) -> i32 {
if depth == 0 {
return state.evaluate();
}
let mut board_value;
if maximise {
... | true |
c771638b2c23f57fefd4fef8113143646dd277fc | Rust | bokuweb/docx-rs | /docx-core/src/documents/elements/table_borders.rs | UTF-8 | 7,388 | 3.3125 | 3 | [
"MIT"
] | permissive | use serde::Serialize;
use crate::documents::BuildXML;
use crate::types::*;
use crate::xml_builder::*;
/*
Please see. L.4.3.2.18 Cell Border Properties
left – left border
right – right border
top – top border
bottom – bottom border
insideH – inner horizontal borders
insideV – inner vertica... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.