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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e4b407992d1903da23358c6b86ced10d9321effa | Rust | luke-titley/imgui-docking-rs | /imgui-gfx-examples/examples/custom_textures.rs | UTF-8 | 4,044 | 2.953125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use gfx::texture::{FilterMethod, SamplerInfo, WrapMode};
use image::ImageFormat;
use imgui::*;
use std::error::Error;
mod support;
#[derive(Default)]
struct CustomTexturesApp {
my_texture_id: Option<TextureId>,
lenna: Option<Lenna>,
}
struct Lenna {
texture_id: TextureId,
size: [f32; 2],
}
impl Cust... | true |
9525649b73870dfcbe6c30a7e31c14d38d5539ab | Rust | Breadinator/matv_dating_sim | /src/main.rs | UTF-8 | 2,381 | 3.1875 | 3 | [] | no_license | use rand::Rng;
use std::io;
static NAMES: [&str; 8] = [
"Sam",
"Producer Jeff",
"Greg",
"Boombot",
"Gary",
"Anne",
"Raze",
"Ash",
];
static HAIRS: [&str; 3] = [
"Blonde",
"Brunette",
"Redhead",
];
static GENDERS: [&str; 3] = [
"Man",
"Woman",
"Non-binary",
];
static LOCATIONS: [&str;... | true |
2aab48b0d9226eb7e01eb5943cc414d0deda3ad6 | Rust | dobrakmato/renderer | /renderer/src/render/object.rs | UTF-8 | 2,364 | 2.96875 | 3 | [] | no_license | //! Temporary helper struct to allow rendering of meshes with materials.
use crate::render::pools::{UniformBufferPool, UniformBufferPoolError};
use crate::render::transform::Transform;
use crate::render::ubo::ObjectMatrixData;
use crate::render::{descriptor_set_layout, OBJECT_DATA_UBO_DESCRIPTOR_SET};
use crate::resou... | true |
1ee895eda9f08e406d959a64b134c15d0ebeed8f | Rust | TrionProg/pz5 | /src/to_pz5/writer.rs | UTF-8 | 3,226 | 2.875 | 3 | [] | no_license | use std;
use config;
/*
use rustc_serialize::base64::{ToBase64, STANDARD};
pub struct Pz5Writer<'a>{
config:config::write::Config<'a>,
binary_data:Vec<&'a Vec<u8> >,
}
impl<'a> Pz5Writer<'a>{
pub fn new(writer:& mut Writer) -> Pz5Writer<'a>{
Pz5Writer{
config:config::write::Config::new... | true |
26383a9a38d1af69bd6bb410d023026b15605102 | Rust | lawliet89/aurene | /src/main.rs | UTF-8 | 5,233 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use clap::{crate_authors, crate_name, crate_version, App, AppSettings, Arg, SubCommand};
mod error;
fn make_parser<'a, 'b>() -> App<'a, 'b> {
let launch = SubCommand::with_name("launch")
.about(
"Launch Guild Wars 2 with saved login profiles\n\n\
Provide directories or files whic... | true |
8be2c37277c39c073b6b6d59dc033ee1c0ff14db | Rust | Devolutions/proxy-cfg | /src/env.rs | UTF-8 | 2,509 | 2.9375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive |
use super::*;
use std::env;
pub(crate) fn get_proxy_config() -> Result<Option<ProxyConfig>> {
let vars: Vec<(String, String)> = env::vars().collect();
let mut proxy_config: ProxyConfig = Default::default();
for (key, value) in vars {
let key = key.to_lowercase();
if key.ends_with("_proxy"... | true |
87d293eba5ac8add0decbde0d8a0e83379f1ae41 | Rust | yasuyuky/sectora | /src/structs.rs | UTF-8 | 8,733 | 2.671875 | 3 | [
"MIT"
] | permissive | use crate::error::{Error, ParseSectorError, ParseSectorGroupError, ParseSectorTypeError};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
use std::fs::File;
use std::io::Read;
use std::str::FromStr;
use std::string::ToString;
#[derive(Deserialize, Debug, Clone)]
pub struct Config {
... | true |
625120dc883d160f0e8ff9e171f4978473312aa4 | Rust | Lokathor/vkvk | /src/entry.rs | UTF-8 | 13,115 | 2.78125 | 3 | [] | no_license | #![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
//! Provides the [Entry] type, and related helper types.
use crate::prelude::*;
#[cfg_attr(windows, link(name = "vulkan-1"))]
#[cfg_attr(not(windows), link(name = "vulkan"))]
#[cfg(FALSE)]
extern "system" {
fn vkGetInstanceProcAddr(instance: VkInstance, n... | true |
05ab423e29b0f3241eaaddafd25e08961cb93e1d | Rust | zwazel/learning-rust | /src/main.rs | UTF-8 | 913 | 3.53125 | 4 | [] | no_license | // Input/Output library, std is the standard library
use std::io;
use crate::numberguesser::numberguesser::guess_the_number;
mod numberguesser;
fn main() {
println!("Hello, world!");
loop {
println!("- Type 0 to exit the game");
println!("- Type 1 to play a number guessing game!");
l... | true |
9ea97636225395e242110d44b181fdaa46b27618 | Rust | tuxmark5/north | /lang_llvm_sys/src/serializer.rs | UTF-8 | 10,507 | 2.703125 | 3 | [] | no_license | use {
crate::{
context::Context,
},
llvm_sys::{
core as llvm_core,
prelude::*
},
serde::{Serialize, ser},
std::{
error, ptr, result,
fmt::{self, Display},
},
};
////////////////////////////////////////////////////////////////////////////////////////////////
static NATIVE_TAG: &'static... | true |
f0ea0ab8b5e013a775bd70bbac360421d7c41e27 | Rust | adumbidiot/scratch-native | /src/scratch/target.rs | UTF-8 | 4,206 | 2.515625 | 3 | [] | no_license | use crate::scratch::{
PyGameIndexFile,
ScratchError,
ScratchResult,
};
pub use crate::scratch_crate::{
client::Client,
util::{
make_command,
FileCreater,
},
Project,
};
use scratch_crate::target::Target;
use std::process::Stdio;
fn test_import(data: &str) -> ScratchResult<bo... | true |
6256a1ca60fdb13667300b4294dee416998a84f5 | Rust | danhper/diem | /sdk/src/types.rs | UTF-8 | 4,527 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{
client::AccountAddress,
crypto::{
ed25519::{Ed25519PrivateKey, Ed25519PublicKey},
traits::Uniform,
},
transaction_builder::TransactionBuilder,
types::transaction::{authenticator::Authenti... | true |
b7de06862e98d22fed98b1e3415880754c61a392 | Rust | andywarduk/aoc2015 | /day15/src/main.rs | UTF-8 | 4,363 | 3.296875 | 3 | [] | no_license | use memmap::Mmap;
use regex::Regex;
use std::{fs::File, io::{BufRead, BufReader}, ops::{AddAssign, Mul}};
const TEASPOONS: usize = 100;
const CALORIE_TARGET: usize = 500;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let lines = load_input("input15.txt")?;
let ingredients = parse_ingredients(&lines);... | true |
b809925b4ff1ddc0823e292733d9568ee5b5b6ee | Rust | tscott0/aoc2020 | /src/d22p2.rs | UTF-8 | 3,168 | 3.234375 | 3 | [] | no_license | use std::{
collections::{hash_map::DefaultHasher, HashSet, VecDeque},
hash::{Hash, Hasher},
};
use crate::utils::string_from_file;
pub fn run() {
let input = string_from_file("src/22input");
println!("{}", solve(input));
}
#[derive(Hash)]
struct GameState {
p1_deck: VecDeque<usize>,
p2_deck:... | true |
c551ed7d6cc133b1bbe94fb9e4940574c03cd844 | Rust | theonewolf/aoc2018 | /day3/src/main.rs | UTF-8 | 2,991 | 3.265625 | 3 | [
"MIT"
] | permissive | use std::env;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
#[derive(Debug)]
#[derive(PartialEq)]
struct Claim {
id: u64,
x: u64,
y: u64,
w: u64,
h: u64
}
impl Claim {
fn from_string(raw: &str) -> Claim {
let cleaned = raw.replace('#', "").repl... | true |
f976412b6ffeb56ed91ce022d6242515abb09977 | Rust | alrus2797/Recommend | /connections/books_connection/src/lib.rs | UTF-8 | 5,907 | 2.921875 | 3 | [] | no_license | #[macro_use]
extern crate diesel;
pub mod schema;
pub mod models;
use diesel::prelude::*;
use diesel::pg::PgConnection;
use std::collections::HashMap;
use common_macros::hash_map;
use connection_manager::{ItemTrait, UserTrait, ConnectionManager};
use self::schema::*;
use self::models::*;
#[derive(Debug)]
pub struc... | true |
2a99c3abdc31ba94f17456af67b887298ff5786c | Rust | basiliqio/ciboulette | /src/errors.rs | UTF-8 | 4,970 | 3.078125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::*;
use thiserror::Error;
/// When describing KeyClash, we need to know if the field was supposed be with
/// or without another field
#[derive(Debug, PartialEq)]
pub enum CibouletteClashDirection {
With,
Without,
}
impl std::fmt::Display for CibouletteClashDirection {
fn fmt(&self, f: &mut std:... | true |
35b19b4f27181ada4ceb32d618e87e19b328d0fb | Rust | CodeChain-io/remote-trait-object | /remote-trait-object/src/transport/multiplex.rs | UTF-8 | 3,882 | 3.109375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::packet::PacketView;
use crate::transport::{Terminate, TransportError, TransportRecv};
use crate::Config;
use crossbeam::channel::{self, Receiver, Sender};
use parking_lot::Mutex;
use std::thread;
pub struct MultiplexedRecv {
recv: Receiver<Result<Vec<u8>, TransportError>>,
}
impl TransportRecv for Mult... | true |
0e8bcb35230a50294c5fbe19372ba46f6098a37a | Rust | kinnergit/rust_learning | /src/raii.rs | UTF-8 | 172 | 2.890625 | 3 | [] | no_license | pub fn create_box(i: i32)
{
let _x = Box::new(i);
}
pub fn create_box_with_range(start: i32, end: i32)
{
for i in start .. end
{
create_box(i)
}
}
| true |
c48bd03ba68d8ca0a838eb96980e09731ecb9ac5 | Rust | MrPans/msbt-rs | /src/section/ato1.rs | UTF-8 | 833 | 2.6875 | 3 | [
"MIT"
] | permissive | use crate::{
Msbt,
traits::CalculatesSize,
};
use super::Section;
use std::ptr::NonNull;
#[derive(Debug)]
pub struct Ato1 {
pub(crate) msbt: NonNull<Msbt>,
pub(crate) section: Section,
pub(crate) _unknown: Vec<u8>, // large collection of 0xFF
}
impl Ato1 {
pub fn new_unlinked<V: Into<Vec<u8>>>(unknown_by... | true |
296f223df66081d0e3462324200dcc784d290f59 | Rust | D0ntPanic/tpscube | /tools/solvebench/src/main.rs | UTF-8 | 3,508 | 2.78125 | 3 | [
"MIT",
"GPL-3.0-only"
] | permissive | use std::time::Instant;
use tpscube_core::{
Cube, Cube2x2x2, Cube3x3x3, Cube4x4x4, InitialCubeState, SimpleSeededRandomSource,
};
fn main() {
let mut rng = SimpleSeededRandomSource::new();
for _ in 0..10 {
let mut cube = Cube2x2x2::sourced_random(&mut rng);
let start = Instant::now();
... | true |
ef6605438cb1d026547ddf618dd7bf1877c9548e | Rust | Zach41/webdemo | /src/request/url.rs | UTF-8 | 2,481 | 3.09375 | 3 | [] | no_license | use url_ext::{self, Host};
use std::fmt;
#[derive(Clone, PartialEq, Eq)]
pub struct Url {
inner: url_ext::Url,
}
impl Url {
pub fn parse(input: &str) -> Result<Url, String> {
match url_ext::Url::parse(input) {
Ok(url) => Url::from_generic_url(url),
Err(e) => Err(format!("Parsi... | true |
63a2c5e7259579c28083f16b1955e6074618482b | Rust | NLnetLabs/bcder | /src/lib.rs | UTF-8 | 2,196 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | //! Handling of data in Basic Encoding Rules.
//!
//! This crate allows decoding and encoding of data encoded in ASN.1’s _Basic
//! Encoding Rules_ as defined in ITU recommendation X.690 as well as their
//! stricter companions _Cannonical Encoding Rules_ and _Distringuished
//! Encoding Rules._
//!
//! You will find a... | true |
8dc8fc47096b3e7375faa4f2dd7446c85de4ce42 | Rust | rvarago/mini-balancer | /src/balancing/middleware/client.rs | UTF-8 | 826 | 2.953125 | 3 | [
"MIT"
] | permissive | //! Opens a Tcp client connection.
use super::{Pipe, PipeError};
use anyhow::Context;
use async_trait::async_trait;
use std::net::SocketAddr;
use tokio::net::TcpStream;
use tracing::{debug, info};
/// A client connector.
#[derive(Debug)]
pub struct Client;
/// Constructs a new [Client].
pub fn connect() -> Client {
... | true |
842f7e9eee080950fa5bec584121ae9c59f85918 | Rust | biaoma-ty/arrow-datafusion | /datafusion/common/src/functional_dependencies.rs | UTF-8 | 20,871 | 2.8125 | 3 | [
"Apache-2.0",
"MIT",
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | true |
168fff565f8684cb76d2218cabca9efde386ffd4 | Rust | Co-Epi/app-backend-rust | /src/networking.rs | UTF-8 | 4,368 | 2.796875 | 3 | [
"MIT"
] | permissive | use core::fmt;
use log::*;
use reqwest::{
blocking::{Client, Response},
Error,
};
use std::error;
static BASE_URL: &str = "https://zmqh8rwdx4.execute-api.us-west-2.amazonaws.com/v4/tcnreport/0.4.0";
// static BASE_URL: &str = "https://v1.api.coepi.org/tcnreport/v0.4.0";
static UNKNOWN_HTTP_STATUS: u16 = 520;
... | true |
eb67f7dc0fbe391cb826a03ad3d490d375caab0f | Rust | fahlmant/adventofcode | /2020/day5/p2/p2.rs | UTF-8 | 678 | 3.0625 | 3 | [
"MIT"
] | permissive | use std::fs;
fn main() {
let contents = fs::read_to_string("../input").unwrap();
let mut full_seats: Vec<isize> = Vec::new();
for line in contents.trim().split('\n') {
let seat = &line.to_string().replace("F", "0").replace("B","1").replace("L", "0").replace("R","1");
let row = isize::fro... | true |
295bf29ac11ed0242685a3e32483e3b73621d8d6 | Rust | TheBambino/terry | /terraria-protocol/src/packets/tweak_item.rs | UTF-8 | 2,515 | 2.796875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::packets::PacketBody;
use crate::SliceCursor;
/// Tweak Item (FKA. Alter Item Drop).
///
/// Direction: Server -> Client.
#[derive(Debug)]
pub struct TweakItem {
pub item_index: i16,
/// BitFlags: 1 = Color, 2 = Damage, 4 = Knockback, 8 = UseAnimation, 16 = UseTime, 32 = Shoot, 64 = ShootSpeed, 128 =... | true |
5b97a10996a2791317b3edfa3a97b323927e3279 | Rust | osaware/rCore-N | /os/src/trap/usertrap.rs | UTF-8 | 2,995 | 2.59375 | 3 | [
"MIT"
] | permissive | const MAX_USER_TRAP_NUM: usize = 128;
use crate::mm::PhysPageNum;
use crate::plic::Plic;
use alloc::{collections::BTreeMap, sync::Arc, vec::Vec};
use lazy_static::*;
use spin::Mutex;
#[derive(Clone)]
pub struct UserTrapInfo {
pub user_trap_buffer_ppn: PhysPageNum,
pub user_trap_record_num: usize,
pub devi... | true |
f1a90fc7827dbb48b1172ebf75c46c375fae5685 | Rust | gnoliyil/fuchsia | /third_party/rust_crates/vendor/mio-0.8.2/src/sys/unix/net.rs | UTF-8 | 6,351 | 3.03125 | 3 | [
"BSD-2-Clause",
"MIT"
] | permissive | use std::io;
use std::mem::size_of;
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
pub(crate) fn new_ip_socket(addr: SocketAddr, socket_type: libc::c_int) -> io::Result<libc::c_int> {
let domain = match addr {
SocketAddr::V4(..) => libc::AF_INET,
SocketAddr::V6(..) => l... | true |
0352b245b003c78de4ffcc7446988e7facb12e62 | Rust | JAD3N/blocky-rs | /blocky-nbt/src/tag/parser/reader.rs | UTF-8 | 4,029 | 3.84375 | 4 | [
"MIT"
] | permissive | pub struct Reader {
text: String,
chars: Vec<char>,
position: usize,
}
impl Reader {
pub fn new<S: Into<String>>(s: S) -> Self {
let text = s.into();
let chars = text.chars().collect();
Self {
text,
chars,
position: 0,
}
}
pu... | true |
d9335eff8c8973e63ae49847192350eb96f13eb4 | Rust | katis/rust-webgl-demo | /src/render_system.rs | UTF-8 | 9,961 | 2.515625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::assets::{ImageId, Images};
use crate::components::Position;
use crate::gl::{Buffer, Gl, Image, Program, Shader, TypedBuffer};
use shrev::EventChannel;
use specs::prelude::*;
use specs::{SystemData, WriteStorage};
use std::rc::Rc;
use vek::column_major::Mat4;
use vek::{FrustumPlanes, Vec2};
use web_sys::WebGl... | true |
7b4398d336e717adf6bd09633d3bc6c09d3b608d | Rust | skanev/playground | /advent-of-code/2021/day13/src/main.rs | UTF-8 | 1,882 | 3.265625 | 3 | [] | no_license | use std::{collections::HashSet, fs};
type Point = (usize, usize);
type Fold = (char, usize);
fn parse_input() -> (HashSet<Point>, Vec<Fold>) {
let text = fs::read_to_string("../inputs/13").unwrap();
let mut input = text.split("\n\n");
let points = input
.next()
.unwrap()
.lines()
... | true |
8507cf63bbeaaed66b4306c45cda7fe1bccd2e0c | Rust | Kevinwochan/Advent-of-Code | /2021/Day2/src/main.rs | UTF-8 | 394 | 3.09375 | 3 | [] | no_license | use std::fs;
use std::collections::VecDeque;
fn main() {
struct Action {
scalar: u32,
direction: String,
}
let input = fs::read_to_string("input.txt")
.expect("Something went wrong reading the file");
let mut depth=0;
let mut horizontal=0;
for action in input {
... | true |
3cfaa8ead921474d24a0f28b029a9e9a76544af7 | Rust | nnsnico/news-tour | /src/settings.rs | UTF-8 | 947 | 2.609375 | 3 | [] | no_license | use config::{Config, ConfigError, File};
use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub struct Slack {
pub scheme: String,
pub domain: String,
pub post_message_endpoint: String,
pub token_key: String,
}
#[derive(Debug, Deserialize)]
pub struct Bot {
pub channel: String,
pub as_user:... | true |
2eb810836a1db4d079c376d957bc65d5ad2525ee | Rust | RyuuGan/rust-problems | /src/sum_pairs.rs | UTF-8 | 1,562 | 3.59375 | 4 | [] | no_license | use std::collections::HashMap;
fn main() {
let l1 = [1, 4, 8, 7, 3, 15];
let l2 = [1, -2, 3, 0, -6, 1];
let amount = sum_pairs(&l2, -6);
println!("{:?}", amount);
}
fn sum_pairs_slow(ints: &[i8], s: i8) -> Option<(i8, i8)> {
let mut found: Option<(i8, i8)> = None;
let mut max_idx = ints.len();
for i in... | true |
3ad896a15418c8cc0a32a3eee0ae30802a161b65 | Rust | hmunozb/simd-phys-rs | /src/r3/fields.rs | UTF-8 | 968 | 2.96875 | 3 | [] | no_license | use crate::vf64::Aligned4xf64;
use crate::r3::{dot_product, norm_sq};
use num_traits::Zero;
///
/// The cartesian harmonic potential
/// u(v1, v2) = (1/2) k |v1 - v2|^2
pub fn harmonic_cartesian(
v1: &[Aligned4xf64; 3], v2: &[Aligned4xf64; 3], k: f64
) -> Aligned4xf64{
let mut u = Aligned4xf64::zero();
f... | true |
0ab4ccd7b901132e2d5c4f0876d33a8b845298a8 | Rust | FliegendeWurst/fend | /core/src/date/day_of_week.rs | UTF-8 | 766 | 3.46875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::fmt;
#[derive(Clone, Copy, PartialEq, Eq)]
pub(crate) enum DayOfWeek {
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
}
impl fmt::Debug for DayOfWeek {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
Self::Su... | true |
dc152466b51c38367ee1cfaef83ca08abf2947d4 | Rust | TheRenegadeCoder/sample-programs | /archive/r/rust/minimum-spanning-tree.rs | UTF-8 | 4,062 | 3.46875 | 3 | [
"MIT"
] | permissive | use std::env::args;
use std::process::exit;
use std::str::FromStr;
use std::collections::{HashMap, HashSet};
fn usage() -> ! {
println!("Usage: please provide a comma-separated list of integers");
exit(0);
}
fn parse_int<T: FromStr>(s: &str) -> Result<T, <T as FromStr>::Err> {
s.trim().parse::<T>()
}
fn ... | true |
51f1e26b71ec2b6067cf7f29ec09edc5655c0e08 | Rust | mengsuenyan/rmath | /src/rand/iter.rs | UTF-8 | 1,724 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | use crate::rand::{RandError, Source, PrimitiveType};
use std::marker::PhantomData;
pub struct Iter<'a, T, P>
where P: PrimitiveType, T: 'a + Source<P> {
pub(super) inner: &'a mut T,
pub(super) last_err: Option<RandError>,
pub(super) ph: PhantomData<P>,
}
impl<'a, T, P> Iter<'a, T, P>
where P: Pr... | true |
0e2a00793dbf444d2170faeb3476bb1940fd9169 | Rust | graydon/nperf | /src/maps.rs | UTF-8 | 4,157 | 3.0625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use regex::Regex;
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Region {
pub start: u64,
pub end: u64,
pub is_read: bool,
pub is_write: bool,
pub is_executable: bool,
pub is_shared: bool,
pub file_offset: u64,
pub major: u32,
pub minor: u32,
pub inode: u64,
pub nam... | true |
a83cbc38e3b1e0b1937ee016bb8ae44ef2b0df26 | Rust | thopper21/AoC20-RS | /src/days/day8.rs | UTF-8 | 3,151 | 3.328125 | 3 | [] | no_license | use crate::day::Day;
use std::collections::HashSet;
pub struct Day8;
enum Op {
Nop(i64),
Acc(i64),
Jmp(i64),
}
struct Program {
instructions: Vec<Op>,
ip: i64,
accumulator: i64,
}
enum TerminalStatus {
Loops(i64),
Terminates(i64),
}
impl Program {
fn new(instructions: Vec<Op>) ... | true |
5eb17f4b5aded577c9397385646bb11c92ba5a1e | Rust | prabhanshu1/rust-compiler | /Assign_IR/final_testcases/ftest5.rs | UTF-8 | 325 | 2.9375 | 3 | [] | no_license | struct T{
a : i32,
b : i32,
c : i32,
d : i32 ,
}
fn main (){
let x : T =T{a:4,b:5,c:6,d:7};;
let y : T =T{a:4,b:5,c:6,d:7};;
printf("a=%d",x.a);
printf("b=%d",x.b);
printf("c=%d",x.c);
printf("d=%d",x.d);
x.a=100;
y.a=145;
printf("New a in y=%d",y.a);
printf("New a=%d",x.a);
return... | true |
f269f3aa6f4ce94c10912393535e98c53a85e2a7 | Rust | manta1130/Competitive_Programming_Template_Rust | /src/vectools.rs | UTF-8 | 1,389 | 3.03125 | 3 | [
"Unlicense"
] | permissive | //提出時は下と一番下のコメントアウトを外す。
//mod vectools {
///C++のupper_boundと同等の実装
pub fn upper_bound<T>(v: &Vec<T>, k: T) -> usize
where
T: PartialOrd,
{
let mut from = 0;
let mut to = v.len();
while to - from > 1 {
let mid = (from + to) / 2;
if v[mid] <= k {
from = mid;
} else {
... | true |
08ca9c8db4a9f19d561b01242edbdd8a6e220b5c | Rust | Celeo/wiki_grapher | /src/parser/models.rs | UTF-8 | 496 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | #[derive(Debug)]
pub(crate) struct PageInfo {
pub(crate) title: String,
pub(crate) links: Vec<String>,
}
impl PageInfo {
pub(crate) fn new(title: &str, links: Vec<String>) -> Self {
Self {
title: title.to_owned(),
links,
}
}
pub(crate) fn to_pairs(&self) -> ... | true |
02b021ecacd111a30a98c6a9bb27ee2d080ee2c3 | Rust | omegablitz/distributary | /src/flow/migrate/routing.rs | UTF-8 | 12,292 | 3.0625 | 3 | [] | no_license | //! Functions for adding ingress/egress nodes.
//!
//! In particular:
//!
//! - New nodes that are children of nodes in a different domain must be preceeded by an ingress
//! - Egress nodes must be added to nodes that now have children in a different domain
//! - Egress nodes that gain new children must gain channel... | true |
9fe920ed0617110feb3c6f534080f5a7271c5fac | Rust | xd009642/ndarray-dsp | /src/lib.rs | UTF-8 | 450 | 2.875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | /// Discrete Cosine Transform
pub mod dct;
/// Discrete Fourier Transform
pub mod dft;
/// Trait for a forward transform to move a matrix into the frequency domain
pub trait ForwardTransformExt {
type Output;
fn transform(self) -> Self::Output;
}
/// Trait for an inverse transform to move from the frequency ... | true |
1929b50add522928decb45f77b4e0f263cc4a256 | Rust | scalexm/hashmap | /src/hash_map/mod.rs | UTF-8 | 6,751 | 2.640625 | 3 | [] | no_license | mod virtual_bucket;
use self::virtual_bucket::{ResizeNeeded, VirtualBucket};
use crate::atomic_arc::{Arc, AtomicArc, NullableAtomicArc};
use std::hash::{BuildHasher, Hash, Hasher};
use std::sync::atomic::{AtomicU64, AtomicU8, Ordering};
pub use fxhash::FxBuildHasher as DefaultBuildHasher;
pub struct HashMap<K, V, S ... | true |
8520638f57355a7de1527b2afdd102f93825495c | Rust | YeFan000/crosvm | /vm_control/src/lib.rs | UTF-8 | 25,270 | 2.65625 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Handles IPC for controlling the main VM process.
//!
//! The VM Control IPC protocol is synchronous, meaning that each `VmRequest` sent over a conn... | true |
ebbd0d69ae3e337254cd8616e10b1f1d9258fbf2 | Rust | Kixiron/prometheus-rs | /src/error.rs | UTF-8 | 1,131 | 2.984375 | 3 | [
"Zlib"
] | permissive | use std::{error::Error, fmt};
pub type Result<T> = std::result::Result<T, PromError>;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PromError {
message: String,
kind: PromErrorKind,
}
impl PromError {
pub(crate) fn new(message: impl Into<String>, kind: PromErrorKind) -> Self {
Self {
... | true |
201e91267cae5a21758bb8ea6148699176d8f0eb | Rust | project-sapphire/prism-rust | /src/serialize/transact.rs | UTF-8 | 801 | 2.71875 | 3 | [] | no_license | use ::zmq;
use ::{Message, ReceiveError};
use ::{Invoice};
impl Message for Invoice {
fn send(&self, socket: &zmq::Socket, flags: i32) -> Result<(), zmq::Error> {
socket.send_str(&self.address, flags | zmq::SNDMORE)?;
socket.send_str(&self.currency, flags | zmq::SNDMORE)?;
socket.send_str... | true |
5ff2b49da6e3190aa328213575f349f66b806f2c | Rust | marcinja/grin | /api/src/rest.rs | UTF-8 | 3,224 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2018 The Grin Developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... | true |
0d70b6ac766a820f3304bcb3976e1d8795a11d4c | Rust | chritchens/overchain-lib | /src/lib.rs | UTF-8 | 21,488 | 2.578125 | 3 | [] | no_license | extern crate num;
extern crate rand;
extern crate byteorder;
extern crate arrayvec;
extern crate crypto;
extern crate secp256k1;
extern crate bitcoin;
extern crate serde;
#[allow(unused_imports)]
#[macro_use] extern crate serde_derive;
use bitcoin::util::hash::{ Hash160, Sha256dHash };
use bitcoin::blockdata::opcodes:... | true |
4571cbda717a26784efbb7ffa47a3b3acd30d84f | Rust | Al-Kindi-0/tfhe | /src/tlwe.rs | UTF-8 | 6,185 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | use crate::lwe::{LweParams, LweSample};
use crate::numerics::{gaussian32, torus_polynomial_mul_r};
use crate::polynomial::{IntPolynomial, Polynomial, TorusPolynomial};
use itertools::Itertools;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct TLweParameters {
... | true |
8565c21c72f39d8ef750adb8ec7eeb5820b49f17 | Rust | anderoo/game-of-life | /src/cell.rs | UTF-8 | 2,619 | 3.984375 | 4 | [] | no_license | use rand::Rng;
use std::fmt;
#[derive(Clone, PartialEq, Debug)]
pub enum CellKind {
ALIVE,
DEAD,
}
#[derive(Clone, PartialEq, Debug)]
pub struct Cell {
pub kind: CellKind,
}
impl fmt::Display for Cell {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.kind == CellKind::ALIVE {
... | true |
04c15c4afba0849f63e16f2927ee48bdc356042d | Rust | knokko/wasmuri-text | /src/model.rs | UTF-8 | 5,744 | 3.265625 | 3 | [
"MIT"
] | permissive | use web_sys::WebGlBuffer;
use web_sys::WebGlRenderingContext;
use web_sys::WebGlRenderingContext as GL;
use wasmuri_core::*;
use super::shaders::TextProgram;
use super::Font;
use std::rc::Rc;
/// Instances of TextModel can be used to draw text on their webgl context. They can be created with the create_text_model
/... | true |
ba96663b58bb2aa61f250835f144a10efc1cd5d9 | Rust | Noah2610/LD43-NihilisticNurtureNavigation | /src/menu/stats/mod.rs | UTF-8 | 2,060 | 2.609375 | 3 | [] | no_license | pub mod prelude {
pub use super::super::Menu;
pub use super::StatsMenu;
pub use super::helpers::StatsText;
pub use super::helpers::TextOrigin;
}
mod helpers;
use ggez::{
Context,
GameResult,
};
use noframe::geo::prelude::*;
use noframe::entity::Entity;
use self::helpers::*;
use super::prelude::*;
use sco... | true |
3183db0e29a938c0aad0ceecb0806b7c7cfbe7b0 | Rust | OrangeBacon/adventofcode2019 | /src/day6a.rs | UTF-8 | 1,657 | 3 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use indexmap::IndexMap;
pub fn day6a() {
let path = Path::new("data/day6.txt");
let display = path.display();
let mut file = match File::open(&path) {
Err(why) => panic!("Couldn't open {}: {}", display, why.des... | true |
adc8c147096c6c6f9cb35966a9e79b907d6bfa61 | Rust | fncnt/rsmpi | /src/topology/cartesian.rs | UTF-8 | 16,398 | 3.078125 | 3 | [
"Apache-2.0",
"DOC",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::mem;
use conv::ConvUtil;
use super::{AsCommunicator, Communicator, IntoTopology, Rank, UserCommunicator};
use crate::ffi::MPI_Comm;
use crate::{
datatype::traits::*, ffi, raw::traits::*, with_uninitialized, with_uninitialized2, Count,
IntArray,
};
/// Contains arrays describing the layout of the
///... | true |
603ed32520bf042267ed0c865965e5e50bcf96cf | Rust | AbleOS/sovos | /libs/uefi/src/memory.rs | UTF-8 | 4,728 | 2.8125 | 3 | [] | no_license | use impl_bits::impl_bits;
#[repr(transparent)]
pub struct MapKey(pub(crate) u64);
#[repr(C)]
pub struct Descriptor {
/// Type of the memory region. Type EFI_MEMORY_TYPE is defined in the
/// AllocatePages() function description.
pub typ: u32,
_padding: u32,
/// Physical address of the first byte... | true |
243fc52ee1ca7a1976d0909bdefa732fb3ab1701 | Rust | nickbryan/zville | /src/camera.rs | UTF-8 | 6,654 | 2.640625 | 3 | [
"MIT"
] | permissive | use bevy::input::mouse;
use bevy::math;
use bevy::prelude::{Plugin as BevyPlugin, *};
use bevy_mod_picking::{PickingGroup, PickingMethod, PickingSource};
use std::f32::consts::PI;
pub const STARTUP_STAGE: &str = "camera_startup_stage";
pub struct Plugin;
impl BevyPlugin for Plugin {
fn build(&self, app: &mut App... | true |
ce65ac6d758fb69f23fad725b9e5435c32f7c32f | Rust | chinedufn/landon | /blender-mesh/src/vertex_attributes/single_indexed/interleave.rs | UTF-8 | 3,993 | 3.796875 | 4 | [
"MIT"
] | permissive | use crate::vertex_attributes::VertexAttribute;
use crate::SingleIndexedVertexAttributes;
/// An error while interleaving vertex data
#[derive(Debug, thiserror::Error)]
pub enum InterleaveError {
/// Likely a mistake when creating the slice of vertex attributes
#[error("Only {num_provided} buffers were provided... | true |
906eb561f23d00a064feeac9f1fa0a90b7cec07a | Rust | gnoliyil/fuchsia | /tools/jq5/src/main.rs | UTF-8 | 10,084 | 2.71875 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use anyhow;
use fuchsia_async;
use futures::future::join_all;
use io::BufWriter;
use json5format::{Json5Format, ParsedDocument};
use std::{
ffi::OsStri... | true |
44b0f6cbfcbb7c7545e1cb04a596aabb832d92dd | Rust | KennyKangMPC/boltzmann | /benches/quadtree_bench.rs | UTF-8 | 1,142 | 2.6875 | 3 | [] | no_license | #![feature(test)]
extern crate test;
extern crate boltzmann;
extern crate rand;
use boltzmann::quadtree::Quadtree;
use boltzmann::collision::*;
use boltzmann::vector::Vector;
use std::cmp::Ordering;
#[cfg(test)]
mod tests {
use super::*;
use test::Bencher;
#[bench]
fn bench_quadtree(b: &mut Benche... | true |
21aa016afdbb2bb4b0d8977727ce86dfbeeafeb9 | Rust | Huynhhung0/solana | /core/src/ledger_cleanup_service.rs | UTF-8 | 10,435 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | //! The `ledger_cleanup_service` drops older ledger data to limit disk space usage
use solana_ledger::blockstore::Blockstore;
use solana_ledger::blockstore_db::Result as BlockstoreResult;
use solana_measure::measure::Measure;
use solana_metrics::datapoint_debug;
use solana_sdk::clock::Slot;
use std::string::ToString;
... | true |
54cf0235bcfec97bbc15a41bed7175bd5e676b35 | Rust | lythesia/leet | /rs/src/quests/multiply_strings.rs | UTF-8 | 1,574 | 3.609375 | 4 | [] | no_license | /**
* [43] Multiply Strings
*
* Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.
Note: You must not use any built-in BigInteger library or convert the inputs to integer directly.
Example 1:
Input: num1 = "2", num2 = "3"
Output:... | true |
e700c50b288804123844c3c42d3d4cc21f1a9873 | Rust | Snarpix/gluon | /vm/src/core/pretty.rs | UTF-8 | 12,598 | 2.671875 | 3 | [
"MIT"
] | permissive | use itertools::Itertools;
use pretty::{self, DocAllocator};
use crate::base::{
symbol::Symbol,
types::{Type, TypeExt},
};
use crate::core::{Alternative, Expr, Literal, Named, Pattern};
const INDENT: isize = 4;
fn ident<'a, A>(
arena: &'a pretty::Arena<'a, A>,
name: &'a Symbol,
) -> pretty::DocBuilde... | true |
b027bb97d313175f446f3fcf3140bc825db9337c | Rust | afprusin/leetcode-rust | /src/bin/560_subarray_sum_equals_k.rs | UTF-8 | 1,041 | 3.421875 | 3 | [] | no_license | use std::collections::HashMap;
struct Solution {}
impl Solution {
pub fn subarray_sum(nums: Vec<i32>, k: i32) -> i32 {
if nums.len() == 0 {
return 0;
}
let mut current_sum = 0;
let mut sum_counts: HashMap<i32, i32> = HashMap::new();
sum_counts.insert(0, 1);
... | true |
c3fda6097ec395eb505ec68e628ca0c7ab598e7b | Rust | TrAyZeN/state-space | /src/priority_queue.rs | UTF-8 | 2,525 | 3.5 | 4 | [
"MIT"
] | permissive | use std::cmp::Ordering;
use std::collections::BinaryHeap;
#[derive(Clone)]
pub struct MinPrioriyQueue<T> {
heap: BinaryHeap<InvertedPriority<T>>,
}
impl<T: Eq> MinPrioriyQueue<T> {
/// Creates a new empty `MinPrioriyQueue<P, E>`.
#[inline]
pub fn new() -> Self {
Self {
heap: Binary... | true |
1516afa751214ba7de3f33fe8cc6fe65f7c0cb8a | Rust | oxcable/basic-devices | /src/dynamics/limiter.rs | UTF-8 | 2,347 | 3.125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! A limiter.
use oxcable::types::{AudioDevice, MessageReceiver, Sample, Time};
use oxcable::utils::helpers::decibel_to_ratio;
use oxcable::level_detector::LevelDetector;
/// Defines the messages that the Limiter supports.
#[derive(Clone, Copy, Debug)]
pub enum Message {
/// Sets the limiting threshold, in deci... | true |
79dcf873adcf9457ea188e4fb06bcf4435f2a2a2 | Rust | yjmyzz/vosk-rs | /examples/audio_input.rs | UTF-8 | 3,371 | 2.640625 | 3 | [] | no_license | use argh::FromArgs;
use portaudio_rs::device::DeviceInfo;
use portaudio_rs::stream::{Stream, StreamCallbackResult, StreamFlags, StreamParameters};
use std::collections::BTreeMap;
use vosk::{Model, Recognizer};
#[derive(FromArgs)]
/// Receive audio and recognize speeches
struct ListenUp {
/// input device to get au... | true |
092f0a7863bcf6af7f0492fcfbecd1a229290927 | Rust | y-oksaku/Competitive-Programming | /AtCoder/abc/159b_2.rs | UTF-8 | 755 | 2.765625 | 3 | [] | no_license | #![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::*;
use std::collections::*;
use std::cmp::*;
use std::mem::swap;
use std::f64::consts::*;
const MO... | true |
ae9b5fd61aeb4479f32e7224b600ed816e9ce5f0 | Rust | rdelfin/jocat | /src/systems/input.rs | UTF-8 | 1,618 | 2.71875 | 3 | [] | no_license | use crate::{
animation::AnimationId,
components::Player,
input::{ActionBinding, GameBindingTypes},
};
use amethyst::{
animation::{get_animation_set, AnimationControlSet},
derive::SystemDesc,
ecs::{prelude::*, Entities, Join, Read, ReadStorage, System, WriteStorage},
input::InputHandler,
... | true |
88a48add17bd47f36adddf8c88e75ac35e417687 | Rust | Smart-Charging/helium-wallet-rs | /src/cmd/onboard.rs | UTF-8 | 4,231 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | use crate::{
cmd::{
api_url, get_password, get_payer, load_wallet, print_json, status_json, Opts, OutputFormat,
},
result::Result,
staking,
traits::{Sign, Signer, TxnPayer, B64},
};
use helium_api::{BlockchainTxn, PendingTxnStatus, Txn};
use serde_json::json;
use std::io;
use structopt::Stru... | true |
e4adcb73c2b74a0cb7042467aff04e9544e5e205 | Rust | neon-bindings/neon | /crates/neon/src/handle/root.rs | UTF-8 | 8,038 | 2.921875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::{ffi::c_void, marker::PhantomData};
use crate::{
context::Context,
handle::Handle,
object::Object,
sys::{raw, reference},
types::boxed::Finalize,
};
#[cfg(feature = "napi-6")]
use {
crate::{
lifecycle::{DropData, InstanceData, InstanceId},
sys::tsfn::ThreadsafeFunction... | true |
79babe8da9997fa18fd80ba2f21b1d39903f93fa | Rust | Bugvi-Benjamin-M/Kattis | /rust/add-two-numbers/src/main.rs | UTF-8 | 412 | 3.09375 | 3 | [
"MIT"
] | permissive | use std::io;
fn input () -> String
{
let mut ret = String::new();
io::stdin().read_line(&mut ret).expect("Failed to read from stdin");
ret
}
fn main() {
let input = input().trim().to_owned();
let mut numbs = input.split_ascii_whitespace();
let a: u32 = numbs.next().unwrap().parse().unwrap();
... | true |
d2682dd72db2f3828f84e842ef8df88df179dd5a | Rust | gridbugs/statecs | /src/templates/entity_mut.rs | UTF-8 | 1,693 | 2.78125 | 3 | [
"MIT"
] | permissive | pub const ENTITY_MUT: &'static str = r#"
pub trait EntityMut: Entity {
type EcsMut: EcsMut;
fn ecs_mut(&mut self) -> &mut Self::EcsMut;
{{#each data_components}}
fn mut_{{name}}(&mut self) -> Option<&mut {{type}}> {
let id = self.id();
self.ecs_mut().get_mut_{{name}}(id)
}
fn mut_p... | true |
cca3fed15e33af6f268dab918cc5b28debcbbb06 | Rust | GaloisInc/mir-verifier | /lib/libcore/num/dec2flt/num.rs | UTF-8 | 2,759 | 3.6875 | 4 | [] | permissive | //! Utility functions for bignums that don't make too much sense to turn into methods.
// FIXME This module's name is a bit unfortunate, since other modules also import `core::num`.
use crate::cmp::Ordering::{self, Equal, Greater, Less};
pub use crate::num::bignum::Big32x40 as Big;
/// Test whether truncating all b... | true |
c8f25de41c89911ad94706e8dca102920226ace5 | Rust | starcoinorg/starcoin | /vm/parallel-executor/src/txn_last_input_output.rs | UTF-8 | 4,008 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{
errors::Error,
scheduler::{Incarnation, TxnIndex, Version},
task::{ExecutionStatus, Transaction, TransactionOutput},
};
use arc_swap::ArcSwapOption;
use crossbeam::utils::CachePadded;
use std::{collections::... | true |
cf07af05371f90bf9bbe7d690a2ab01297b721b8 | Rust | xujihui1985/learningrust | /buildpattern/src/main.rs | UTF-8 | 2,292 | 3.34375 | 3 | [] | no_license | use std::marker::PhantomData;
#[derive(Debug)]
pub struct Request {
url: String,
method: String,
headers: Vec<(String,String)>,
body: Option<String>,
}
// region: States
#[derive(Default, Clone)]
pub struct NoUrl;
#[derive(Default, Clone)]
pub struct Url(String);
#[derive(Default, Clone)]
pub struct ... | true |
0ec59a589e564112f5fb552a801472c136d72a57 | Rust | origel/origel | /programs/netutils/src/httpd/main.rs | UTF-8 | 5,242 | 2.734375 | 3 | [
"MIT"
] | permissive | #![cfg_attr(not(target_os = "redox"), feature(libc))]
use std::{env, str};
use std::fs::{self, File};
use std::io::{Error, ErrorKind, Result, Read, Write};
use std::net::TcpListener;
use std::path::Path;
fn read_dir(root: &Path, path: &Path) -> Result<(Vec<u8>, Vec<u8>)> {
let mut names = vec![];
for entry in... | true |
aa64d5b5157545be603ff8934cb255fc9b0a5c8b | Rust | jhejderup/praezi-stats | /src/lib.rs | UTF-8 | 1,676 | 2.625 | 3 | [
"MIT"
] | permissive | extern crate semver;
extern crate libc;
use semver::{Version,VersionReq};
use libc::c_char;
use std::ffi::CStr;
#[no_mangle]
pub extern fn is_match(req: *const c_char, ver: *const c_char) -> bool {
let req_str = unsafe {
assert!(!req.is_null());
CStr::from_ptr(req)
};
let ver_str = unsafe ... | true |
489140352d98f5aca4eaba708ab5236834d32bdc | Rust | iterum-provenance/iterum-rust | /src/version_control/commit.rs | UTF-8 | 5,743 | 3.3125 | 3 | [] | no_license | use super::error::{VCErrorMessage, VersionControlError};
use super::{Commit, Dataset, VersionTreeNode};
impl Dataset {
/// Adds a commit to a dataset, but first perform integrity checks whether the commit can be added
pub fn add_commit(mut self, commit: &Commit) -> Result<Dataset, VersionControlError> {
... | true |
1f4935cdea562812358337823fa58269a77e2dd2 | Rust | zeta1999/snake_01 | /src/game.rs | UTF-8 | 22,653 | 2.875 | 3 | [
"MIT"
] | permissive | extern crate rand;
use rand::Rng;
use std::collections::VecDeque;
use std::fmt;
use crate::constants::*;
use crate::gen_alg::NN;
use crate::qlearn::QLearner;
pub trait Brain {
fn get_action(&mut self, inputs: &Vec<f64>) -> Option<usize>;
fn train(&mut self, state_initial: &Vec<f64>, action: usize, reward: f6... | true |
ac263a4534d29b76f34451c7d7028c2a69615699 | Rust | dgurnani12/SEGIMAP | /core/src/command/store.rs | UTF-8 | 3,288 | 3.34375 | 3 | [
"MIT"
] | permissive | use std::ascii::AsciiExt;
use std::collections::HashSet;
use folder::Folder;
use message::Flag;
use message::parse_flag;
use self::StoreName::{Add, Replace, Sub};
use super::sequence_set;
/// Representation of a STORE operation
pub enum StoreName {
Replace, // replace current flags with new flags
Add, // add... | true |
a668e68984ebe90392204ae50188d1df09f8e466 | Rust | RemiTorracinta/pants | /src/rust/engine/process_execution/bazel_protos/build.rs | UTF-8 | 4,908 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | use protoc_grpcio;
use std::path::{Path, PathBuf};
use build_utils::BuildRoot;
fn main() {
let build_root = BuildRoot::find().unwrap();
let thirdpartyprotobuf = build_root.join("3rdparty/protobuf");
println!(
"cargo:rerun-if-changed={}",
thirdpartyprotobuf.to_str().unwrap()
);
let amended_proto_ro... | true |
be34f381e09a64fa0d8e6eedc8a366e6b2e56350 | Rust | exceptional-lang/exceptional | /src/compiler.rs | UTF-8 | 6,761 | 3.484375 | 3 | [] | no_license | use ast::*;
use instructions::*;
use std::rc::Rc;
fn compile_statement(statement: &Statement) -> InstructionSequence {
match statement {
&Statement::Assign(local, ref binding_name, ref expression) => {
let mut instructions = compile_expression(expression);
let instruction = match lo... | true |
6387a85b571869b468f1245e001e1be63515d943 | Rust | xcaptain/rust-algorithms | /leetcode/src/p633.rs | UTF-8 | 652 | 3.421875 | 3 | [] | no_license | // https://leetcode-cn.com/problems/sum-of-square-numbers/
pub fn judge_square_sum(c: i32) -> bool {
let mid = (c as f64).sqrt() as i32;
for a in 0..=mid {
let exp_b = ((c - a * a) as f64).sqrt() as i32;
if exp_b * exp_b + a * a == c {
// println!("{}, {}, {}", a, exp_b, c);
... | true |
203962578a69ca3b306dcaf2c6e6cc2ad79f2c3c | Rust | martindines/libpnet | /src/packet/ipv4.rs | UTF-8 | 4,246 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright (c) 2014, 2015 Robert Clipsham <robert@octarineparrot.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modifi... | true |
ef80cde67493eb85978aca4b7bcdd221dbf18da2 | Rust | alokmenghrajani/random_stuff | /cryptopals/src/set2/challenge12.rs | UTF-8 | 4,613 | 2.734375 | 3 | [] | no_license | /**
* Byte-at-a-time ECB decryption (Simple)
*
* Copy your oracle function to a new function that encrypts buffers under ECB mode using a
* consistent but unknown key (for instance, assign a single random key, once, to a global
* variable).
*
* Now take that same function and have it append to the plaintext, BEF... | true |
6455a3eb46b757f4ad4b3623bf48e0b5b56c3c01 | Rust | afonsolage/craft-world | /src/resources/player.rs | UTF-8 | 242 | 2.671875 | 3 | [] | no_license | use amethyst::ecs::prelude::*;
#[derive(Default)]
pub struct MainPlayer {
pub entity: Option<Entity>,
}
impl MainPlayer {
pub fn new(entity: Entity) -> Self {
MainPlayer {
entity: Some(entity),
}
}
}
| true |
e0276b436abf7fc3c37a519b85844dff5de2cdf8 | Rust | jacklund/cryptopals_old | /src/challenges/set_2/challenge15.rs | UTF-8 | 700 | 2.703125 | 3 | [] | no_license | #[cfg(test)]
mod tests {
use crate::exception::CryptoError;
use crate::util::validate_pkcs7_padding;
// Fifteenth cryptopals challenge - https://cryptopals.com/sets/2/challenges/15
#[test]
fn challenge15() {
assert_eq!(
Ok("ICE ICE BABY".as_bytes().to_vec()),
validat... | true |
8adbfbb869b7da6c5d0457d2f2c8ac3473dd7edb | Rust | jiangzhe/mudterm | /src/event.rs | UTF-8 | 3,068 | 2.734375 | 3 | [
"MIT"
] | permissive | use crate::error::Result;
use crate::runtime::{Engine, RuntimeOutputHandler};
use crate::runtime::timer::Timer;
use crate::runtime::delay_queue::Delay;
use crate::ui::line::RawLine;
use crate::ui::UserOutput;
use crossbeam_channel::Receiver;
use std::net::{SocketAddr, TcpStream};
use termion::event::{Key, MouseEvent};
... | true |
e81fa186f4dae21fc9f5a37f2d66de4ef2809087 | Rust | geniousli/point24 | /src/algorithm/house_robber_iii.rs | UTF-8 | 1,590 | 3.328125 | 3 | [] | no_license | use std::rc::Rc;
use std::cell::RefCell;
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
impl TreeNode {
#[inline]
pub fn new(val: i32) -> Self {
TreeNode {
val,
... | true |
9756e0c16cf783623104c10fdaff15783bb9bb04 | Rust | praveenperera/m3u | /src/iptv/parse_extinf/test.rs | UTF-8 | 2,347 | 2.9375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::parse_extinf;
use super::IptvExtInf;
use crate::iptv;
#[test]
fn example() {
let s = r#"#EXTINF:-1 tvg-id="" tvg-name="TF1",TF1"#;
assert_eq!(
parse_extinf(s),
Some(IptvExtInf {
duration_secs: -1.0,
name: "TF1".into(),
iptv_props: iptv!("tvg-id" = ... | true |
3287e62275026b7f18013041a1bcaf02aa3734bf | Rust | bpzj/tex-rs | /src/section_1034.rs | UTF-8 | 5,873 | 2.53125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! @ We leave the |space_factor| unchanged if |sf_code(cur_chr)=0|; otherwise we
//! set it equal to |sf_code(cur_chr)|, except that it should never change
//! from a value less than 1000 to a value exceeding 1000. The most common
//! case is |sf_code(cur_chr)=1000|, so we want that case to be fast.
//!
//! The overal... | true |
fa17914ad7b1615e3b20c223127b90027626375d | Rust | schicks/ruddis | /src/lib/domain.rs | UTF-8 | 1,925 | 3.046875 | 3 | [
"MIT"
] | permissive | use std::collections::HashSet;
#[cfg(test)]
use proptest_derive::Arbitrary;
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
#[cfg_attr(test, derive(Arbitrary))]
pub enum Primitive {
String(String),
Number(i64),
}
impl std::fmt::Display for Primitive {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::f... | true |
39e404959d28066fe23418b440bc9fd35ca2eb53 | Rust | mas-yo/static_ecs | /src/component.rs | UTF-8 | 8,156 | 3.28125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::hash::Hash;
pub trait ID {
fn next(&self) -> Self;
}
// #[derive(Clone, Copy, Eq, PartialEq, Hash, Default)]
// pub struct EntityID {
// id: u32,
// }
// impl EntityID {
// pub fn new() -> Self {
// Self { id: 0 }
// }
// pub fn next(&self) -> Self {... | true |
fb0f2ae2e5fe6af01b4540c76cbc05697f7e126b | Rust | Ltei/cumath | /src/cuvector/math.rs | UTF-8 | 11,370 | 3.03125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive |
use super::*;
/// Vector math operations
pub struct CuVectorMath<T: CuDataType> {
_phantom: PhantomData<T>
}
impl CuVectorMath<i32> {
/// output[i] = vector[i] + value
pub fn add_value(vector: &CuVectorDeref<i32>, value: i32, output: &mut CuVectorDeref<i32>, stream: &CudaStream) {
unsafe { Vect... | true |
78cdf3bbe8e920a1ecf53f0734eee38e74aa454f | Rust | ryankurte/rust-daemon | /src/tcp.rs | UTF-8 | 5,289 | 2.671875 | 3 | [] | no_license | /**
* rust-daemon
* TCP Server and Connection Implementations
*
* https://github.com/ryankurte/rust-daemon
* Copyright 2018 Ryan Kurte
*/
use std::fmt::{Debug};
use std::clone::{Clone};
use std::net::SocketAddr;
use tokio::prelude::*;
use tokio::spawn;
use tokio_codec::{Encoder, Decoder};
use tokio_tcp::{TcpLi... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.