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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e25466577384e3055d31797318fdd7ffc065f050 | Rust | wdv4758h/toy-http | /src/main.rs | UTF-8 | 2,282 | 3.234375 | 3 | [] | no_license | #![feature(convert)] // for String.as_str
use std::env;
use std::fs; // fs::read_dir
use std::net::{TcpListener, TcpStream};
use std::io::Write; // for stream.write
trait HTTPHandler {
fn http_response(&self, stream: &TcpStream);
}
trait TCPServer {
fn serve(&self);
fn handler(&self,... | true |
94dca69745c6f0b4a9aa52f115d3f90c3a1b84c1 | Rust | Smithay/smithay | /src/utils/fd.rs | UTF-8 | 1,544 | 2.734375 | 3 | [
"MIT"
] | permissive | #![forbid(unsafe_op_in_unsafe_fn)]
use std::{
os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, OwnedFd, RawFd},
path::PathBuf,
sync::Arc,
};
/// Ref-counted file descriptor of an open device node
#[derive(Debug, Clone)]
pub struct DeviceFd(Arc<OwnedFd>);
impl PartialEq for DeviceFd {
fn eq(&self,... | true |
bd01db7227c1157735caafcec6e4b5802124b245 | Rust | jhpratt/standback | /build.rs | UTF-8 | 2,546 | 2.796875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use version_check::{Channel, Version};
// We assume that features are never stabilized in patch versions.
// If a "Rust 2.0" is ever released, we'll have to handle that explicitly.
const MSRV_MINOR: u16 = 36;
const CURRENT_MINOR: u16 = 60;
fn main() {
let msrv = Version::from_mmp(1, MSRV_MINOR, 0);
let mut m... | true |
f823507dffe4900bb716d72c825b065c8dd0a918 | Rust | eugene-bulkin/nanodb-rust | /src/server/client.rs | UTF-8 | 1,840 | 2.9375 | 3 | [] | no_license | //! The module containing NanoDB client instances.
use nom::IResult::*;
use rustyline::Editor;
use rustyline::error::ReadlineError;
use ::parser::statements;
use ::server::Server;
const PROMPT: &'static str = "CMD> ";
/// A NanoDB client which connects to the server and executes user-input commands.
pub struct Clie... | true |
4921bd63bb964969b6de958542954724e0db2503 | Rust | ridiculousfish/regress | /src/pikevm.rs | UTF-8 | 16,444 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! PikeVM regex execution engine
use crate::api::Match;
use crate::bytesearch::charset_contains;
use crate::cursor;
use crate::cursor::{Backward, Direction, Forward};
use crate::exec;
use crate::indexing::{AsciiInput, ElementType, InputIndexer, Utf8Input};
use crate::insn::{CompiledRegex, Insn, LoopFields};
use crate... | true |
d31a2bd0ae0e563c44e736e9a2aa965b9f5d3766 | Rust | Pick1a1username/Mastering-Python-Design-Patterns-Second-Edition-In-Rust | /chapter10/command_2/src/lib.rs | UTF-8 | 9,419 | 3.921875 | 4 | [
"MIT"
] | permissive | //! # Command Pattern (2)
//!
//! This module is an example of command pattern based on the code written in Python.
//! The original Python code is [this](https://github.com/PacktPublishing/Mastering-Python-Design-Patterns-Second-Edition/blob/master/chapter10/command.py).
//!
//! This example has the following command... | true |
f6e98ea3e50ce00aadc1ef270de2d8151033a8c8 | Rust | isgasho/epd | /src/command.rs | UTF-8 | 2,578 | 2.84375 | 3 | [] | no_license | //! Command Table
#[repr(u8)]
pub enum Command {
/// Set the number of gate
///
/// <<A:u8, 0:b5, B:b3>>
DriverOutputControl = 0x01,
/// Set Gate driving voltage
///
/// <<0:b3, A:b5, 0:b4, B:b4>>
GateDrivingVoltageControl = 0x03,
/// Set Source output voltage
///
/// LUT by... | true |
5413cdb9bd92010245ac37117f6a2993aefa821a | Rust | sreeise/ProgrammingSnippets | /Rust/rust_language/src/bin/closures_iterators/mod.rs | UTF-8 | 9,565 | 3.78125 | 4 | [
"MIT"
] | permissive | /*
Code and Definitions from:
https://doc.rust-lang.org/book/2018-edition/ch13-01-closures.html
https://github.com/ProgrammingRust/examples
Closures
1. Rust’s closures are anonymous functions you can save in a variable
or pass as arguments to other functions. You can create the closure in
... | true |
2c1814417f5ae72cbbe9fe0b94c91e727262016a | Rust | oxidecomputer/tock | /boards/components/src/si7021.rs | UTF-8 | 5,443 | 2.59375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Components for the SI7021 Temperature/Humidity Sensor.
//!
//! This provides three Components, SI7021Component, which provides
//! access to the SI7021 over I2C, TemperatureComponent, which
//! provides a temperature system call driver, and HumidityComponent,
//! which provides a humidity system call driver. SI7021... | true |
3cc9e2c061fe4e3e396c13f1a177fc8ffd0c7518 | Rust | vaibhavantil2/third-party-api-clients | /slack/src/team.rs | UTF-8 | 5,183 | 2.9375 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use crate::Client;
pub struct Team {
pub client: Client,
}
impl Team {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
Team { client }
}
/**
* This function performs a `GET` to the `/team.accessLogs` endpoint.
*
* Gets the access logs for the curren... | true |
785f67bc78403ac41b02b30a63383ce47de7d520 | Rust | yuvipanda/atuin | /atuin-client/src/import/bash.rs | UTF-8 | 1,773 | 2.84375 | 3 | [
"MIT"
] | permissive | use std::io::{BufRead, BufReader};
use std::{fs::File, path::Path};
use eyre::{eyre, Result};
use super::count_lines;
use crate::history::History;
#[derive(Debug)]
pub struct Bash {
file: BufReader<File>,
pub loc: u64,
pub counter: i64,
}
impl Bash {
pub fn new(path: impl AsRef<Path>) -> Result<Sel... | true |
e6f6ef805094f95aa1ccba3c7daecb805259c9a8 | Rust | ajit-kolathur/AdventOfCode | /src/days/day8.rs | UTF-8 | 3,675 | 3.546875 | 4 | [] | no_license | use std::collections::HashSet;
use std::path::Path as Path;
use std::time::Instant;
use crate::common::io;
fn run_program_until_loop(instructions: &Vec<String>) -> (i32, i32) {
let mut visited: HashSet<i32> = HashSet::new();
let mut ip = 0;
let mut acc = 0;
while !visited.contains(&ip) && ip < instr... | true |
95e3f8505a9cdfda297f47b014cb1dc98f290ca9 | Rust | Hazelfire/graph_note | /src/model.rs | UTF-8 | 559 | 2.828125 | 3 | [] | no_license | use crate::fields::TextField;
//use std::collections::HashMap;
pub enum FieldType {
String,
Integer,
Double,
Map(Box<FieldType>),
List(Box<FieldType>),
}
pub trait Node {
}
pub struct Model {
pub name: TextField,
// pub fields: HashMap<String, FieldType>
}
impl Model {
pub fn new() ->... | true |
f6cee4069ea862bb10a202919a27d4690c4718bf | Rust | pitpo/AdventOfCode2018 | /days/day19/src/lib.rs | UTF-8 | 4,225 | 3.140625 | 3 | [] | no_license | extern crate utils;
use utils::Day;
struct Instruction {
name: String,
resulting_register: usize,
a_value: usize,
b_value: usize,
}
pub struct Day19 {
instruction_register: usize,
instructions: Vec<Instruction>,
}
impl Day19 {
pub fn new(input: String) -> Day19 {
let mut instruct... | true |
b142bc9be3bd0952975024c06ce1ed1710bdbdd1 | Rust | stackdumper/empty-spaces-rs | /src/resources/textures.rs | UTF-8 | 2,034 | 3.3125 | 3 | [] | no_license | use image::*;
use std::collections::HashMap;
#[derive(Default)]
pub struct Textures {
pub textures: HashMap<u32, Texture>,
}
impl Textures {
pub fn new() -> Self {
let mut textures = HashMap::new();
textures.insert(1, Self::load("src/assets/grass_1.png"));
textures.insert(2, Self::loa... | true |
47545507abb7f66ab8666d1b784ce24dad2cbc4c | Rust | SCappella/exercism | /rust/dot-dsl/src/lib.rs | UTF-8 | 2,940 | 3.46875 | 3 | [
"MIT"
] | permissive | pub mod graph {
use graph_items::edge::Edge;
use graph_items::node::Node;
use std::collections::HashMap;
#[derive(Default)]
pub struct Graph {
pub nodes: Vec<Node>,
pub edges: Vec<Edge>,
pub attrs: HashMap<String, String>,
}
impl Graph {
pub fn new() -> Self... | true |
e1e179d9be37e301325ba98149bd4118cd4d3963 | Rust | Symforian/University | /Rust/List_3/4.Zoom/src/main.rs | UTF-8 | 6,548 | 3.390625 | 3 | [] | no_license | fn zoom(n: i32) -> String {
// Base case
if n == 1 {return "■".to_string();}
// Setting proper color
let mut current_color = "■";
if (n-1)/2%2 == 1 {
current_color = "□";
};
let mut rows:Vec<String> = vec![]; //Remembered rows
let mut res:String = "".to_string(); //Result
let... | true |
63ce824ad1ba7a286a89fca50ecccaa4b2643421 | Rust | gicmo/heimweh | /src/main.rs | UTF-8 | 5,909 | 2.6875 | 3 | [] | no_license | #[macro_use]
extern crate clap;
extern crate git2;
extern crate rustc_serialize;
extern crate toml;
use std::path::{Path, PathBuf};
use std::fs::{self, DirEntry};
use std::{io, env};
use clap::{App, ArgMatches, SubCommand};
use git2::build::RepoBuilder;
mod config;
use config::Config;
mod castle;
use castle::Castle... | true |
1b4cd1538d5b75847d722bf08004222d302282d2 | Rust | waonder-rs/scene | /src/scene.rs | UTF-8 | 5,238 | 3.140625 | 3 | [] | no_license | use std::{
ops::{
Deref,
DerefMut
},
borrow::{
Borrow,
BorrowMut
},
convert::{
AsRef,
AsMut
},
sync::{
Arc,
Weak
},
hash::{
Hash,
Hasher
},
marker::PhantomData
};
use slab::Slab;
use crossbeam_queue::SegQueue;
use crate::Event;
struct State {
grabs: SegQueue<usize>,
releases: SegQueue<... | true |
0634d16a4fd286b188c445c65d1eea61d2dd31d6 | Rust | fewensa/telegrambot | /src/api/get_chat_administrators.rs | UTF-8 | 828 | 2.828125 | 3 | [
"MIT"
] | permissive | use reqwest::Method;
use crate::api::req::HttpReq;
use crate::api::resp::RespType;
use crate::api::TGReq;
use crate::errors::TGBotResult;
use crate::types::*;
/// Use this method to get a list of administrators in a chat.
/// If the chat is a group or a supergroup and no administrators were appointed,
/// only the cr... | true |
d78526ab4c66602a883dd58286445997242024da | Rust | konradsz/adventofcode2017 | /day01/rust/captcha.rs | UTF-8 | 980 | 3.40625 | 3 | [] | no_license | use std::fs;
fn captcha(input1: &Vec<u32>, input2: &Vec<u32>) -> u32 {
let mut sum = 0;
for (first, second) in input1.iter().zip(input2.iter()) {
if first == second {
sum += first;
}
}
sum
}
fn main() {
let contents = fs::read_to_string("../input")
.expect("file... | true |
c8e2d44603d1715e07b00df110fb2d020ad9155f | Rust | Disasm/nrf-hal | /nrf-hal-common/src/adc.rs | UTF-8 | 4,507 | 2.515625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! API for the Analog to Digital converter.
use embedded_hal::adc::{Channel, OneShot};
use core::hint::unreachable_unchecked;
use crate::{
gpio::{Floating, Input},
pac::{
adc::config::{INPSEL_A as InputSelection, REFSEL_A as Reference, RES_A as Resolution},
ADC,
},
};
pub struct Adc(ADC... | true |
e04d78737845609dba36ed5893b2c9d14acdc422 | Rust | Ruin0x11/autotile | /src/terrain.rs | UTF-8 | 827 | 3.21875 | 3 | [] | no_license | #[derive(Eq, PartialEq, Clone, Debug)]
pub enum Feature {
Door,
UpStair,
DownStair,
}
#[derive(Eq, PartialEq, Copy, Clone, Debug)]
pub enum Terrain {
Wall,
Floor,
Important,
Nothing,
}
impl Terrain {
pub fn to_char(&self) -> char {
match *self {
Terrain::Wall => '#'... | true |
47d64925c43db0e156140e7e53b9e470bfcea951 | Rust | kroeckx/ruma | /crates/ruma-client-api/src/r0/appservice/set_room_visibility.rs | UTF-8 | 1,449 | 2.8125 | 3 | [
"MIT"
] | permissive | //! [PUT /_matrix/client/r0/directory/list/appservice/{networkId}/{roomId}](https://matrix.org/docs/spec/application_service/r0.1.2#put-matrix-client-r0-directory-list-appservice-networkid-roomid)
use ruma_api::ruma_api;
use ruma_identifiers::RoomId;
use crate::r0::room::Visibility;
ruma_api! {
metadata: {
... | true |
919cf594bb50e2eed353dd1ec0306efa18aa4ce1 | Rust | xcaptain/rust-algorithms | /leetcode/src/p1311.rs | UTF-8 | 3,266 | 3.125 | 3 | [] | no_license | // https://leetcode-cn.com/problems/get-watched-videos-by-your-friends/
use std::cmp::Ordering;
use std::collections::HashMap;
use std::collections::VecDeque;
pub fn watched_videos_by_friends(
watched_videos: Vec<Vec<String>>,
friends: Vec<Vec<i32>>,
id: i32,
level: i32,
) -> Vec<String> {
let lev... | true |
fb0cd4fcf9fd575e9f4b0fa862b0baede4c991c2 | Rust | Ppjet6/zeerust | /src/cpu/opcodes/test.rs | UTF-8 | 31,879 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use crate::cpu::opcodes::opcode;
#[allow(unused_imports)]
use crate::ops::Op;
use crate::ops::{
JumpConditional::*,
Location16::{Immediate as I16, ImmediateIndirect as II16, Reg as R16},
Location8::*,
Op::*,
Reg16::*,
Reg8::*,
};
macro_rules! op4 {
($o1 : expr) => {
[$o1, 0x00, 0x00... | true |
5ad701644963626a51b9ef8961f30f79171c13e2 | Rust | Happy-Ferret/reproto | /lib/backend-rust/src/rust_compiler.rs | UTF-8 | 3,728 | 2.734375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Compiler for Rust Backend
use super::{EXT, MOD};
use backend::{Environment, PackageProcessor, PackageUtils};
use backend::errors::*;
use core::{Loc, RpEnumBody, RpInterfaceBody, RpName, RpPackage, RpServiceBody, RpTupleBody,
RpTypeBody, RpVersionedPackage};
use rust_backend::RustBackend;
use rust_file_s... | true |
469d6d968286c85fde2aa4867b963cc2f4d56306 | Rust | rodrimati1992/abi_stable_crates | /abi_stable/src/type_layout/tl_reflection.rs | UTF-8 | 1,885 | 3.15625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use crate::std_types::RStr;
////////////////////////////////////////////////////////////////////////////////
/// Whether a field is accessible,and how it is accessed.
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, StableAbi)]
#[sabi(unsafe_sabi_opaque_fields)]
pub enum FieldAccessor {
/// Accessible with... | true |
1ea43ecbd46f9e8420fd19582f0807b5077911db | Rust | reuvenpo/go-cosmwasm | /src/db.rs | UTF-8 | 1,410 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | use cosmwasm::traits::{ReadonlyStorage, Storage};
use crate::memory::Buffer;
static DB_GET_MAX_RESULT_LENGTH: usize = 2000;
// this represents something passed in from the caller side of FFI
#[repr(C)]
pub struct db_t {}
#[repr(C)]
pub struct DB_vtable {
pub read_db: extern "C" fn(*mut db_t, Buffer, Buffer) -> ... | true |
bf2321d0860434277a1bf88ca0cd58d03cb5d61e | Rust | ikysil/rust99 | /working-with-vectors/P26/src/lib.rs | UTF-8 | 1,349 | 3.3125 | 3 | [] | no_license | pub fn combinations<T: Copy>(k: usize, li: &[T]) -> Vec<Vec<T>> {
fn comb_rec<T: Copy>(k: usize, rem: &[T], acc: &Vec<T>) -> Vec<Vec<T>> {
if k == 1 {
rem.into_iter()
.map(|&x| {
let mut acc2 = acc.clone();
acc2.push(x);
... | true |
5e92c0887c453aa467094ca7ae363a288bdb5c83 | Rust | devpts00/generust | /src/options.rs | UTF-8 | 914 | 2.828125 | 3 | [] | no_license | use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(name = "Generust", author = "devpts00", about = "Data generator tool")]
pub struct Options {
#[structopt(
short,
long,
default_value = "10",
help = "Number of records to generate"
)]
pub count: i32,
#[str... | true |
a294199242be32309a9f2de27bcb0b331119534a | Rust | nrxus/duck_husky_wedding | /src/duck_husky_wedding/screen/menu.rs | UTF-8 | 7,295 | 2.578125 | 3 | [] | no_license | use data;
use errors::*;
use duck_husky_wedding::{button, font};
use glm;
use moho::{self, input};
use moho::renderer::{align, options, ColorRGBA, Font, Renderer, Scene, Texture, TextureLoader,
TextureManager};
use std::rc::Rc;
use sdl2::keyboard::Keycode;
pub struct Image<T> {
texture: Rc<T... | true |
fcb7c16a9e1a97e3ef4e50ae33131c4820ada841 | Rust | ZhongliGao/medis.tk | /tutorial/select.rs | UTF-8 | 5,069 | 3.03125 | 3 | [
"MIT"
] | permissive | use std::future::Future;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::sync::mpsc;
use tokio::sync::oneshot;
use tokio::{net::TcpListener, process};
struct MySelect {
rx1: oneshot::Receiver<&'static str>,
rx2: oneshot::Receiver<&'static str>,
}
impl Future for MySelect {
type ... | true |
fdd2635fa2fd070014ef084657073147c54dbf82 | Rust | BooleanCat/prefab | /src/bin/prefab/config/mount.rs | UTF-8 | 2,024 | 3.390625 | 3 | [] | no_license | use serde_derive::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, PartialEq, Default)]
pub struct Mount{
pub destination: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub source: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub options: Option<V... | true |
b063c5638b632171dfc6b0f5ea6067575ba43eb0 | Rust | kiedtl/th | /lib/src/dun_s2.rs | UTF-8 | 1,445 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use crate::dun_s1::*;
use crate::features::*;
use serde::{Serialize, Deserialize};
use std::vec::Vec;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct DungeonTile {
pub tiletype: TileType,
pub tile_material: String,
// TODO: define Item structs
pub items: Vec<u8>,
pub mobs: Op... | true |
116d840f769d6e62a9d9c365ff5ce67e2f4a42d0 | Rust | jamen/views | /src/look.rs | UTF-8 | 2,668 | 3.328125 | 3 | [] | no_license | use core::marker::PhantomData;
use crate::{View,ViewMut,Bytes,BytesMut,BadPos};
/// Temporarily look into a buffer
///
/// Similar to a slice except you're able to restore the original buffer after slicing it. This can
/// be useful for knowing your position in the buffer and looking back. This can be done with two
/... | true |
54b0fd6643ed27da4d93ab99d43025d4a744295d | Rust | isra17/adventofcode2017 | /src/bin/day5.rs | UTF-8 | 1,125 | 3.484375 | 3 | [] | no_license | use std::fs::File;
use std::io::Read;
fn run_maze(sheet: &str, inc_threshold: Option<i64>) -> u64 {
let mut jumps: Vec<i64> = sheet.lines().map(|l| l.parse::<i64>().unwrap()).collect();
let mut i: i64 = 0;
let mut n = 0;
while i < jumps.len() as i64 && i >= 0 {
let j = jumps[i as usize];
... | true |
655332aa5254a398bdd51fe37e583c92719c76de | Rust | khskarl/vct-hybrid-voxelization | /src/scene/material.rs | UTF-8 | 3,109 | 3.046875 | 3 | [] | no_license | use image::{DynamicImage, ImageBuffer};
use std::rc::Rc;
pub struct MaterialBuilder {
name: String,
albedo_tex: Option<Rc<Texture>>,
normal_tex: Option<Rc<Texture>>,
metaghness_tex: Option<Rc<Texture>>,
occlusion_tex: Option<Rc<Texture>>,
}
impl MaterialBuilder {
pub fn new(name: String) -> MaterialBuilder {
... | true |
bd238919a4da42a12a04b3638229917587ce9a93 | Rust | adradek/sicp | /1.11/i_solution.rs | UTF-8 | 398 | 3.21875 | 3 | [] | no_license | fn f(n: i32) -> i32 {
if n <= 3 {
return n;
} else {
return f_iter(1, 2, 3, n - 4);
}
}
fn f_iter(nx3: i32, nx2: i32, nx1: i32, cnt: i32) -> i32 {
let nx0 = nx3 + nx2 + nx1;
if cnt == 0 {
return nx0;
} else {
return f_iter(nx2, nx1, nx0, cnt - 1);
}
}
fn ma... | true |
1d8dbb0441ccbeecf1e7478be0da081726605963 | Rust | loganyu/leetcode | /problems/127_word_ladder.rs | UTF-8 | 2,800 | 3.40625 | 3 | [] | no_license | /*
A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that:
Every adjacent pair of words differs by a single letter.
Every si for 1 <= i <= k is in wordList. Note that beginWord does not need to be in wordList.
sk == ... | true |
21a778e3ed119e1b515b4c67961eed8892893582 | Rust | DrunkFlamingo/kailua | /kailua_types/src/ty/display.rs | UTF-8 | 8,198 | 2.96875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::fmt;
use std::cell::RefCell;
use std::collections::{HashSet, HashMap};
use kailua_env::{Span, Spanned};
use kailua_diag::{Locale, Localize, Localized};
use kailua_syntax::Name;
use super::{TypeContext, S, TVar, RVar};
/// A display state to catch recursive types and handle display hints.
pub struct DisplaySt... | true |
b8d9fa4872092b41bed58ab811e7960bbd31d91f | Rust | asampley/fn_cache | /src/fn_cache.rs | UTF-8 | 511 | 3.421875 | 3 | [
"MIT"
] | permissive | /// The generic trait for all caches.
///
/// This trait is implemented on all caches. This allows
/// someone to write a function like
/// `fn f(cache: &mut impl FnCache<u32,u32>, x: &u32) -> u32`
/// and have it work for all the caches written in this crate.
pub trait FnCache<I, O> {
/// Retrieve a value stored in t... | true |
981d7679125013abf0dec8a62c460b5143ceb065 | Rust | mcaveniathor/arx-kw | /src/lqb.rs | UTF-8 | 3,699 | 3.09375 | 3 | [
"MIT"
] | permissive | use chacha::ChaCha;
use byteorder::{ByteOrder,LittleEndian};
use chacha::KeyStream;
use crate::{ArxKwError};
/// A wrapper type that exists solely to allow instantiation of chacha::ChaCha structs with their private fields. The
/// related functions return chacha::ChaCha
/// TODO see if the maintainers of chacha would... | true |
65b09251484d9f0548175ee549d6ae463494cc1d | Rust | willemneal/important-api | /ghstars/src/lib.rs | UTF-8 | 1,443 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | use suborbital::runnable::*;
use suborbital::req;
use suborbital::http;
use suborbital::log;
use suborbital::util;
use serde::{Serialize, Deserialize};
use serde_json;
struct Ghstars{}
#[derive(Serialize, Deserialize)]
struct Repo {
stargazers_count: i32,
}
impl Runnable for Ghstars {
fn run(&self, _: Vec<u8... | true |
0dea1d2c7e2e0fdba248c27a4a7175b074acd4bc | Rust | PhylumChordata/space-invade.rs | /emulator/src/emulator_state.rs | UTF-8 | 1,829 | 3.09375 | 3 | [] | no_license | use crate::memory;
use crate::memory::GRAPHIC_MEMORY_SIZE;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct SharedState {
display: bool,
megahertz: f64,
in_1: u8,
in_2: u8,
is_paused: bool,
}
#[wasm_bindgen]
impl SharedState {
pub fn new() -> SharedState {
SharedState {
... | true |
cfff932754fc17b23d124c3f5abcb2d798c6fd88 | Rust | Zheoni/ray-tracing | /src/object/moving_sphere.rs | UTF-8 | 2,187 | 3.015625 | 3 | [] | no_license | use super::*;
use crate::aabb::surrounding_box;
/// Dynamic sphere that move linealy over time
#[derive(Clone)]
pub struct MovingSphere<M: Material + Clone> {
pub center0: Vec3,
pub center1: Vec3,
pub time0: f64,
pub time1: f64,
pub radius: f64,
pub material: M,
}
impl<M: Material + Clone> Mov... | true |
41e63fc984e01f420c963bf9b9e346d8437f9340 | Rust | joelhy/leetcode-in-rust | /src/n0027_remove_element.rs | UTF-8 | 626 | 3.703125 | 4 | [] | no_license | struct Solution {}
impl Solution {
pub fn remove_element(nums: &mut Vec<i32>, val: i32) -> i32 {
let mut slow = 0;
for fast in 0..nums.len() {
if nums[fast] != val {
nums[slow] = nums[fast];
slow += 1;
}
}
slow as i32
}
}
... | true |
1c949b3588add0ab73f989d2cc78e0f5cd60cda6 | Rust | wdv4758h/cargo-arch | /src/main.rs | UTF-8 | 2,069 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | //! `cargo arch` is a Cargo plugin for making Arch Linux packages.
//! Packages' information is extract from `Cargo.toml`.
//! You can add additional information in `[package.metadata.arch]` section.
use anyhow::{Context, Result};
pub mod cli;
pub mod config;
fn build_arch_package(mksrcinfo: bool,
... | true |
a29523c58ffa351301f7ffb6b8010a40d0313f75 | Rust | himlpplm/rust-tdlib | /src/types/add_favorite_sticker.rs | UTF-8 | 2,187 | 2.90625 | 3 | [
"MIT"
] | permissive | use crate::errors::*;
use crate::types::*;
use uuid::Uuid;
/// Adds a new sticker to the list of favorite stickers. The new sticker is added to the top of the list. If the sticker was already in the list, it is removed from the list first. Only stickers belonging to a sticker set can be added to this list
#[derive(Deb... | true |
d5d24306e56744228d303c957e4c243bee77c253 | Rust | remexre/evaltrees | /src/cst/parser/tests.rs | UTF-8 | 2,178 | 3.140625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::ast::{Literal, Op, Pattern};
use crate::cst::{Decl, Expr};
use crate::repl::ReplCommand;
#[test]
fn calls() {
let expr: Expr = "f x y".parse().unwrap();
assert_eq!(
expr,
Expr::Op(
Op::App,
Box::new(Expr::Op(
Op::App,
Box::new(E... | true |
05f0f37a7d138658302cd10c64edd7a0b5d258c7 | Rust | MHRA/products | /medicines/search-client/src/document_type.rs | UTF-8 | 2,695 | 3.4375 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};
use std::str::FromStr;
#[cfg_attr(
feature = "graphql",
async_graphql::Enum(desc = "Document type (SPC/PIL/PAR)"),
derive(Serialize, Deserialize, Debug, Ord, PartialOrd)
)]
#[cfg_attr(
not(feature = "graphql"),
derive(
... | true |
1d6051547011cd717efe9be6dd7b06e0e28dae42 | Rust | escrichov/rustbook | /ls_cli/src/main.rs | UTF-8 | 588 | 2.75 | 3 | [] | no_license | use std::env;
use std::fs;
use std::path::Path;
fn main() {
let paths = fs::read_dir(&Path::new(&env::current_dir().unwrap())).unwrap();
let names = paths
.map(|entry| {
let entry = entry.unwrap();
let entry_path = entry.path();
let file_name = entry_path.file_nam... | true |
9530d02be28759ce6f1886efb069ee7161ff3112 | Rust | Rufflewind/_urandom | /rust/mutability/buf1.rs | UTF-8 | 3,594 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use std::marker::PhantomData;
// workaround for lack of HKT/ATC
pub trait TypeFn<T: ?Sized> { type Type; }
impl<T: ?Sized> TypeFn<T> for *const () { type Type = *const T; }
impl<T: ?Sized> TypeFn<T> for *mut () { type Type = *mut T; }
impl<'a, T: ?Sized> TypeFn<&'a T> for &'static () { type Type = &'a T; }
impl<'a... | true |
aa96e5cea2e14b995c7ece72728a22587395bbf6 | Rust | AlanRace/voronator-rs | /examples/plot-triangulation.rs | UTF-8 | 1,594 | 2.578125 | 3 | [
"MIT"
] | permissive | extern crate plotters;
extern crate rand;
extern crate voronator;
use plotters::prelude::*;
use rand::prelude::*;
use rand_distr::Uniform;
use voronator::delaunator::Point;
use voronator::delaunator::triangulate_from_tuple;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut rng = rand::thread_rng();
... | true |
e96f5856387b32a84d9d85d58d74b530dee1ed7c | Rust | stalwartlabs/mail-parser | /src/decoders/charsets/mod.rs | UTF-8 | 4,678 | 2.5625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | /*
* Copyright Stalwart Labs Ltd. See the COPYING
* file at the top-level directory of this distribution.
*
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
* https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
* <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
* optio... | true |
88e7196ae61f435f68c1944173c6e91f717c36c7 | Rust | RustWorks/openshift-openapi-codegen | /src/v4_5/api/security/v1/pod_security_policy_review_status.rs | UTF-8 | 3,638 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | // Generated from definition com.github.openshift.api.security.v1.PodSecurityPolicyReviewStatus
/// PodSecurityPolicyReviewStatus represents the status of PodSecurityPolicyReview.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct PodSecurityPolicyReviewStatus {
/// allowedServiceAccounts returns the list of s... | true |
6c575beaf4eb32d0ef6492ce612e83a7d658812b | Rust | codec-abc/rust-path-tracer | /src/tracer/vector/mod.rs | UTF-8 | 1,976 | 3.71875 | 4 | [] | no_license | use std::ops::Add;
use std::ops::Sub;
use std::ops::Rem;
use std::ops::Mul;
#[derive(Copy, Clone)]
pub struct Vector
{
pub x : f64,
pub y : f64,
pub z : f64
}
impl Vector
{
#[allow(dead_code)]
pub fn new_zero() -> Vector
{
Vector { x : 0.0, y : 0.0, z : 0.0}
}
pub fn new(x : f... | true |
a7f5759ff0a7bc310c0b851aa54d962a904f7bdd | Rust | YonicDev/randomprime | /reader_writer/src/uncached.rs | UTF-8 | 2,439 | 2.921875 | 3 | [
"MIT"
] | permissive | use std::{
io,
fmt::{Debug, Formatter, Error},
};
use crate::{
lcow::LCow,
reader::{Reader, Readable},
writer::Writable,
};
pub enum Uncached<'r, T>
where T: Readable<'r>
{
Borrowed(Reader<'r>, T::Args),
Owned(Box<T>),
}
impl<'r, T> Uncached<'r, T>
where T: Readable<'r>,
... | true |
a7329952b8bb3035db3f8de7b3b20b8b9f6c5811 | Rust | hudson-ayers/tock | /capsules/src/virtual_hmac.rs | UTF-8 | 11,398 | 2.671875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Virtualize the HMAC interface to enable multiple users of an underlying
//! HMAC hardware peripheral.
use core::cell::Cell;
use kernel::collections::list::{List, ListLink, ListNode};
use kernel::hil::digest::{self, ClientData, ClientHash, ClientVerify, DigestData};
use kernel::utilities::cells::{OptionalCell, Tak... | true |
accc34c407f1caefc2c4c76b2cfc84081ba07f77 | Rust | stanciua/adventofcode2017 | /day12/src/main.rs | UTF-8 | 3,045 | 3.109375 | 3 | [] | no_license | #[macro_use]
extern crate nom;
use std::str;
use nom::{digit, space};
use std::fs::File;
use std::io::Read;
use std::collections::HashSet;
named!(
program<i32>,
map_res!(map_res!(digit, str::from_utf8), str::parse)
);
named!(
peers<HashSet<i32>>,
map!(
separated_nonempty_list_complete!(tag!(",... | true |
fdd7f26107b3423d85117274057cf93776035ef7 | Rust | TanNgocDo/hbbft | /src/broadcast/merkle.rs | UTF-8 | 4,847 | 3.296875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::mem;
use serde_derive::{Deserialize, Serialize};
use tiny_keccak::sha3_256;
pub type Digest = [u8; 32];
/// A Merkle tree: The leaves are values and their hashes. Each level consists of the hashes of
/// pairs of values on the previous level. The root is the value in the first level with only one
/// entry.... | true |
84aa508842765b1bff4bac29409d6637f444b617 | Rust | aticu/VeOS | /kernel/src/multitasking/mod.rs | UTF-8 | 2,419 | 2.734375 | 3 | [
"MIT"
] | permissive | //! Manages multitasking in the operating system.
mod cpu_local;
mod pcb;
pub mod scheduler;
pub mod stack;
mod tcb;
pub use self::cpu_local::{CPULocal, CPULocalMut};
pub use self::pcb::{get_current_process, PCB};
pub use self::scheduler::CURRENT_THREAD;
pub use self::stack::{Stack, StackType};
pub use self::tcb::{Th... | true |
0a783d85db75711b7b1e3e7a7a81d397c037db46 | Rust | tapaswenipathak/manticore | /kernel/ioport.rs | UTF-8 | 4,493 | 3.53125 | 4 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! PCI I/O port accessors.
/// I/O port that is either MMIO or PIO.
#[derive(Clone, Copy, Debug)]
pub enum IOPort {
Memory { base_addr: usize, size: u32 },
IO { iobase: u16, size: u32 },
}
impl IOPort {
/// Remaps this I/O port to a subset of the I/O port.
///
/// The function returns an `Option<... | true |
393282df32c9df210e0674da2fa3026c4883be70 | Rust | kuririn246/sabun_data_model | /sabun_maker/src/imp/structs/list_def_obj.rs | UTF-8 | 2,642 | 2.828125 | 3 | [] | no_license | use crate::{HashM, HashS};
use crate::imp::structs::list_value::ListDefValue;
use crate::imp::structs::ref_def_obj::RefDefObj;
use std::collections::hash_map::Iter;
#[derive(Debug, PartialEq, Clone)]
pub struct ListDefObj{
default : Box<ListDefMap>,
///RustValueを巨大にしすぎないためにBoxにしてサイズを削る
refs: Box<RefDefObj>... | true |
0b4f15558f9fa939a4c56400eb263f4deeaee20a | Rust | joshuawarner32/mun | /crates/mun_codegen/src/ir/ty.rs | UTF-8 | 5,001 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use inkwell::context::Context;
use super::try_convert_any_to_basic;
use crate::{
type_info::{TypeInfo, TypeSize},
CodeGenParams, CodegenContext,
};
use hir::{
ApplicationTy, CallableDef, FloatBitness, FloatTy, IntBitness, IntTy, ResolveBitness, Ty,
TypeCtor,
};
use inkwell::{
types::{AnyTypeEnum, Ba... | true |
6354f2801bc10201535aaa1df044a295d3ffa067 | Rust | BurntSushi/blog | /code/rust-regex-syntax-extensions/rep-regex-dynamic.rs | UTF-8 | 309 | 2.609375 | 3 | [
"MIT",
"Unlicense"
] | permissive | #![allow(dead_code)] fn main() {}
struct Regex {
insts: Vec<Inst>,
// (N.B. The real representation has a few more things, like the names of
// capture groups or pre-computed data for optimizations, but they are
// elided here to keep things simple.)
}
enum Inst { Match, OneChar, /* ... */ }
| true |
7d1343d246dd7de1e787491d857832e1bde6b5f1 | Rust | COLDTURNIP/raphanus_leetcode | /rust/src/p901.rs | UTF-8 | 3,324 | 3.546875 | 4 | [] | no_license | /*
Problem 901. Online Stock Span
==============================
https://leetcode.com/problems/online-stock-span/
Write a class StockSpanner which collects daily price quotes for some stock, and returns the span
of that stock's price for the current day.
The span of the stock's price today is defined as the maximum ... | true |
b38e802eead0358da3ff5f634c505aecea877cc6 | Rust | cechmanek/learning-rust | /smart_pointers/src/main.rs | UTF-8 | 3,428 | 4.25 | 4 | [] | no_license |
// we need pointers so that we can define data with unknown sizes at compile time,
// such as a linked list
enum LinkedList {
Node(i32, Box<LinkedList>), // node with int value and smart pointer to next LinkedList Node
Nil, // terminal node
}
use crate::LinkedList::{Node, Nil}; // shorthand so we can say Nod... | true |
059574399e2f21d7bd0ff1fbee20949280504012 | Rust | sparshjain265/PoPL | /rust/classNested.rs | UTF-8 | 427 | 3.65625 | 4 | [] | no_license | struct MyType {data : u32 }
impl Drop for MyType
{
fn drop (&mut self)
{
print!("Dropping {}\n", self.data);
}
}
fn main()
{
let x = MyType{data : 0};
let z = MyType{data : 1};
// drop(x); /* This line will result in a move from x */
{
let xp = &x; /* This will give an error if the drop x above is uncomm... | true |
c953e069050be19a778270136bc43dfdf40de154 | Rust | indygreg/starlark-rust | /starlark/bin/dap/library/stream.rs | UTF-8 | 2,157 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright 2019 The Starlark in Rust Authors.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/lic... | true |
970fc4e0e090011226d59115a265a653a469f733 | Rust | placrosse/drogue-device | /src/device.rs | UTF-8 | 2,988 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | //! Types and traits related to the root-level device and system-wide lifecycle events.
use core::cell::{RefCell, UnsafeCell};
use crate::actor::ActorContext;
use crate::prelude::{Address, EventBus, EventHandler};
use crate::supervisor::Supervisor;
/// System-wide lifecycle events.
///
/// See also `NotificationHand... | true |
ffa8403cdd168febd68e12377da608a972309b9e | Rust | rustkas/error-index | /main_tests/tests/e0382.rs | UTF-8 | 1,388 | 3.46875 | 3 | [
"MIT"
] | permissive | /*
This error occurs when an attempt is made to use a variable after its contents have been moved elsewhere.
*/
// cargo test --test e0365 with_error1 -- --nocapture
// cargo test --test e0382 without_error2 -- --nocapture
#[allow(dead_code)]
#[cfg(test)]
mod tests {
#[allow(non_snake_case)]
#[allow(unused_im... | true |
b3af1cfba794a5fb23677cabe99f3eec507a1f50 | Rust | stanislav-tkach/deep_walk | /src/lib.rs | UTF-8 | 1,647 | 3.421875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::path::{Path, PathBuf};
use std::fs::{self, ReadDir, DirEntry};
use std::io::Error;
pub struct DeepWalk {
root: PathBuf,
}
impl DeepWalk {
pub fn new<P: AsRef<Path>>(root: P) -> Self {
DeepWalk { root: root.as_ref().to_path_buf() }
}
}
impl IntoIterator for DeepWalk {
type Item = Resu... | true |
088186a8d0ecc56adeb0bdb79aa8087fe8fc0295 | Rust | michalwa/asciiart | /src/main.rs | UTF-8 | 1,035 | 2.671875 | 3 | [] | no_license | mod console_8x8;
use std::{error::Error, io, path::PathBuf};
use clap::Clap;
#[derive(Clap)]
#[clap(version = "0.1")]
struct Opts {
mode: String,
image_path: PathBuf,
width: u32,
height: u32,
#[clap(short, long)]
invert: bool,
}
fn main() -> Result<(), Box<dyn Error>> {
let opts = Opts::... | true |
1c55c77a62169b1c1de2dba9089866992e82ca8f | Rust | raygon-renderer/thermite | /crates/thermite/src/math/poly.rs | UTF-8 | 7,524 | 3.25 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | /*!
Optimized fixed-degree polynomial evaluation
All of these polynomials use Estrin's scheme to reduce the dependency chain length
and encourage instruction-level parallelism, which has the potential to improve
performance despite the powers of X being required upfront.
Powers of x are required, rather than computed... | true |
4a4886077aba1e8160a1d21693cdb3008e46a764 | Rust | livioribeiro/project-euler | /rust/src/bin/p003.rs | UTF-8 | 1,376 | 3.84375 | 4 | [
"MIT"
] | permissive | //! The prime factors of 13195 are 5, 7, 13 and 29.
//!
//! What is the largest prime factor of the number 600851475143 ?
const INPUT: u64 = 600851475143;
fn main() {
let mut i = (INPUT as f64).sqrt().ceil() as u64;
while i > 1 {
if INPUT % i == 0 && i.is_prime() {
println!("{}", i);
... | true |
d7dab5be66851649bb37fe9f88a51d166d36f153 | Rust | murphybytes/udpscp | /src/server.rs | UTF-8 | 129 | 2.65625 | 3 | [] | no_license |
pub struct Listener {
host: String
}
impl Listener {
pub fn new(host: String) -> Self {
Listener{host}
}
} | true |
812025a29aab0f46b3d60a7cf2a7ccd1a7de1f96 | Rust | tosteiner/thoth | /thoth-app/src/agent/notification_bus.rs | UTF-8 | 1,630 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::HashSet;
use std::fmt;
use yew::agent::Dispatcher;
use yew::worker::*;
pub type NotificationDispatcher = Dispatcher<NotificationBus>;
#[derive(Debug)]
pub enum Request {
NotificationBusMsg((String, NotificationStatus)),
}
#[derive(Debug, Clone)]
pub enum NotificationStatus {
Danger,
... | true |
bd5e27ed9b4aec1ca1d85dc0a8617cb26efc7ac4 | Rust | nickbabcock/collectd-rust-plugin | /src/api/mod.rs | UTF-8 | 27,005 | 2.5625 | 3 | [
"MIT"
] | permissive | pub use self::cdtime::{nanos_to_collectd, CdTime};
pub use self::logger::{collectd_log, log_err, CollectdLoggerBuilder, LogLevel};
pub use self::oconfig::{ConfigItem, ConfigValue};
use crate::bindings::{
data_set_t, meta_data_add_boolean, meta_data_add_double, meta_data_add_signed_int,
meta_data_add_string, met... | true |
2e50ab4e9e4e09a952e87994c2a68c7ee9391ab6 | Rust | jessica-taylor/mercatoria_rust | /src/network/message_sender.rs | UTF-8 | 5,846 | 3 | 3 | [
"MIT"
] | permissive | //! Sending of messages over the network.
use super::event::Event;
use super::log::Log;
use super::message::{Message, MessageContent, MessageId, Reply};
use super::role::Role;
use super::Network;
use anyhow::anyhow;
use async_trait::*;
use core::pin::Pin;
use std::borrow::BorrowMut;
use std::future::Future;
use std::m... | true |
a0078cb257016be0576e1fa1995c03adf53980b4 | Rust | szqh97/test | /rust/arc_test.rs | UTF-8 | 440 | 3.078125 | 3 | [] | no_license | use std::sync::Arc;
use std::thread;
use std::time::Duration;
pub fn main() {
let numbers: Vec<_> = (0..100u32).collect();
let shared_numbers = Arc::new(numbers);
for i in 0..10{
let child_numbers = shared_numbers.clone();
thread::spawn(move ||{
let local_number = &child_number... | true |
c0a66a9f2a88aebb1bb470b02f8f536fda7d1b1b | Rust | RicoGit/rust-alg | /src/leetcode/construct_binary_tree_from_preorder_and_inorder_traversal.rs | UTF-8 | 1,622 | 3.484375 | 3 | [] | no_license | //! 105. Construct Binary Tree from Preorder and Inorder Traversal
// Definition for a binary tree node.
#[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... | true |
b8469a290735d27bdca41134386411ecc0c50bc6 | Rust | bbucko/rusty-pew-pew | /src/sdl/sdl_input_handler.rs | UTF-8 | 1,622 | 3.03125 | 3 | [] | no_license | use super::sdl2::keyboard::KeyboardState;
use super::sdl2::keyboard::Scancode;
use game::InputHandler;
use game::InputState;
use sdl::sdl2::event::Event;
use sdl::SDLEngine;
use sdl::SDLInputHandler;
impl InputHandler for SDLInputHandler {
fn capture(&mut self) -> Vec<InputState> {
let mut input = Vec::new... | true |
eded0d807059ac2da120229beec19e816c2f2501 | Rust | huangjiahua/reredis | /src/object/mod.rs | UTF-8 | 27,932 | 2.6875 | 3 | [
"BSD-3-Clause"
] | permissive | pub mod list;
pub mod dict;
pub mod skip_list;
pub mod int_set;
pub mod zip_list;
pub mod zset;
pub mod linked_list;
use std::time::SystemTime;
use std::cell::RefCell;
use std::rc::Rc;
use std::error::Error;
use list::List;
use zip_list::ZipList;
use dict::{Dict, DictPartialEq};
use int_set::IntSet;
use zset::Zset;
... | true |
35f1466cbd9ef65d3d1a0de12e09476ef0242526 | Rust | astro/rust-lpc43xx | /src/rtc/ctime1/mod.rs | UTF-8 | 1,962 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::CTIME1 {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = r" Value of the field"]
pub struct DOMR {
bits: ... | true |
14211f77a91e42a7bde938c53dc4a9620d6834d7 | Rust | jasonbrackman/advent_of_code_2018 | /src/day_08.rs | UTF-8 | 2,817 | 3.8125 | 4 | [] | no_license | use std::collections::VecDeque;
use std::fmt;
#[derive(Default)]
pub struct Node {
children: i32,
metadata: Vec<i32>,
value: i32,
childs: Vec<Node>,
}
impl fmt::Display for Node {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"Children: {} -> Met... | true |
c7dd2913a649ed60826494f22efa6c9c5877d3a7 | Rust | pzmarzly/x11-input-mirror | /src/config.rs | UTF-8 | 1,424 | 2.640625 | 3 | [
"MIT"
] | permissive | use toml;
use std::fs::File;
use std::io::prelude::*;
use std::net::SocketAddr;
#[derive(Deserialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct ServerConfig {
pub interface_and_port: SocketAddr,
pub max_ping_ms: u64,
}
#[derive(Deserialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struc... | true |
e74e9e1f9f16459f9499d2d8522e9765b6b66f51 | Rust | zsiciarz/euler.rs | /src/solutions/problem45.rs | UTF-8 | 429 | 2.984375 | 3 | [] | no_license | use super::SolutionResult;
fn is_natural(x: f64) -> bool {
(x - x.round()).abs() < 1e-6
}
fn is_pentagonal(x: i64) -> bool {
let x = x as f64;
is_natural(((24.0 * x + 1.0).sqrt() + 1.0) / 6.0)
}
fn hexagonal(n: i64) -> i64 {
n * (2 * n - 1)
}
pub fn solution() -> SolutionResult {
let x = (144..1... | true |
5fa68a0aed6320d08c9bb63a77cceeae7a85419e | Rust | DumbMahreeo/check-ends-macro | /src/lib.rs | UTF-8 | 1,043 | 3.234375 | 3 | [
"MIT"
] | permissive | /// Checks if string starts with any of the `&str`s
#[macro_export]
macro_rules! match_start {
($to_check:expr, $( $( $start:literal)|* => $to_return:expr )* ) => {
if false {None} // This is here to use else if later
$(
else if match_start!(@INTERNAL $to_check, $($start),*) {
... | true |
ee43615fc8ed1c98a1d21065f51d7d69974d15c3 | Rust | fifc/my2postgres | /actid/src/pool.rs | UTF-8 | 3,387 | 2.53125 | 3 | [] | no_license | extern crate yaml_rust;
extern crate rand;
use rand::prelude::*;
use std::io::{BufRead, Write};
use std::collections::HashMap;
//use term::Attr::BackgroundColor;
pub const BASE_ID:u64 = 1000000;
const TOTAL_NUM:u64 = 184779;
pub fn init_pool() -> (Vec<u64>, u64) {
let mut max = TOTAL_NUM;
let res = st... | true |
7e5829e3e8995ed0f973b00de921e56d209ad7dc | Rust | berwyn/ferroboy | /ferroboy/src/operations/add/narrow.rs | UTF-8 | 4,030 | 3.78125 | 4 | [
"MIT"
] | permissive | use crate::{
assembly::{AssemblyInstruction, AssemblyInstructionBuilder, Disassemble},
operations::Operation,
state::State,
system::{Alu, Cartridge, Flags, Register},
};
/// Add the contents of one register to another
///
/// # Opcode Reference
/// ## Assembly definition
/// ```a
/// ADD A,B
/// ```
//... | true |
ff826f306a1f1af4780bc131a70386c9f0ae49b5 | Rust | cfrancia/pantomime-vm | /src/loader.rs | UTF-8 | 3,393 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | use pantomime_parser::ClassFile;
use super::{VirtualMachineError, VirtualMachineResult};
use std::collections::HashMap;
use std::fs::File;
use std::fs::read_dir;
use std::path::PathBuf;
use std::rc::Rc;
pub struct BaseClassLoader {
loaded_classes: HashMap<String, Rc<ClassFile>>,
classfile_paths: Vec<PathBuf>... | true |
a033ae0d95265b45855799c52984f21c1ff37a14 | Rust | bbqsrc/comde | /src/stored.rs | UTF-8 | 1,536 | 2.875 | 3 | [] | no_license | use crate::{com::ByteCount, Compressor, Decompress, Decompressor};
use std::io::copy;
use std::io::{Read, Result, Seek, Write};
#[derive(Debug, Copy, Clone)]
pub struct StoredDecompressor;
impl Decompressor for StoredDecompressor {
fn new() -> Self {
StoredDecompressor
}
fn copy<R: Read, W: Write... | true |
acf353ba5c26c7c523b3f7d0e51f427bcb5b9a35 | Rust | purdue-cap/DryadSynth | /src/meet-middle/src/chatgpt/parsing.rs | UTF-8 | 7,646 | 2.5625 | 3 | [
"MIT"
] | permissive | use ahash::{HashMap, HashMapExt};
use itertools::Itertools;
use thiserror::Error;
use tree_sitter::{Node, Parser, Language};
use crate::{enumerate::expr::OwnedExpr, all_ops, parse::literals::{u64_constant_no_error, u64_constant_python}};
#[derive(Error, Debug)]
#[error("Parsing Error")]
pub struct ParsingError;
exte... | true |
35e0e707d191479bf4c07814d65de067b8d05355 | Rust | reaandrew/rust_proxy | /src/main.rs | UTF-8 | 902 | 2.546875 | 3 | [] | no_license | use reqwest::header::HeaderMap;
use soup::{Soup, QueryBuilderExt, NodeExt};
fn main() {
let user_agent_desktop = include_str!("../resources/useragent.txt");
let base_url = "https://www.sslproxies.org";
let mut headers = HeaderMap::new();
headers.append("User-Agent", user_agent_desktop.parse().unwrap()... | true |
2e0d872b23a7f7f9fd506cfd76b08fb00e7dfc31 | Rust | Zhanghailin1995/nats_rust | /server/src/error.rs | UTF-8 | 1,040 | 3.03125 | 3 | [] | no_license | use std::fmt::Formatter;
use std::error::Error;
pub type Result<T> = std::result::Result<T, NError>;
pub const ERROR_PARSE: i32 = 1;
pub const ERROR_MESSAGE_SIZE_TOO_LARGE: i32 = 2;
pub const ERROR_INVALID_SUBJECT: i32 = 3;
pub const ERROR_SUBSCRIPTION_NOT_FOUND: i32 = 4;
pub const ERROR_CONNECTION_CLOSED: i32 = 5;
... | true |
394852a0d8469fa44b8ed2ae614ef1c36915b856 | Rust | bdalrhm/rmc | /src/test/cbmc/Pointers_Functions/main.rs | UTF-8 | 256 | 2.671875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT
fn main() {
let mut x = 1;
add_two(&mut x);
assert!(x == 3);
}
fn add_two(x: *mut u32) {
unsafe {
*x += 2;
}
}
| true |
8d482ed4dd94f248c955e9011d48da8bbf5ffb7a | Rust | mvolkmann/rust-tokio | /src/main-channels.rs | UTF-8 | 991 | 3.1875 | 3 | [] | no_license | // This demonstrates using channels to process task results
// when they complete rather than waiting for all to complete.
// The Rng trait must be in scope.
use rand::Rng;
use std::sync::mpsc;
use tokio::{
task,
time::{sleep, Duration},
};
#[tokio::main]
async fn main() {
let (tx, rx) = mpsc::channel();
... | true |
35c7ec58385de49d8630854c00cf6c62e8d1ddc5 | Rust | farhan2106/rust-a11n-a12n | /src/domain/user/sign_up.rs | UTF-8 | 1,759 | 2.921875 | 3 | [] | no_license | use validator::{Validate};
use mysql as my;
use bcrypt::{hash};
use crate::domain::user::{generate_random, send_email, SignUpDTO, DTOErrors};
pub fn run(config: &crate::Config, db_conn: &my::Pool, data: &SignUpDTO) -> Result<bool, DTOErrors> {
match data.validate() {
Ok(_) => {
let salt: String... | true |
f62563eb664ff190a188e577beba0d6b26963118 | Rust | OkayAlright/personal-code | /rust/euler/primeSum.rs | UTF-8 | 2,316 | 3.59375 | 4 | [] | no_license | /*
primeSum.rs
----------------------------------------------------------
Description:
A simple prime finder to solver problem
10 : https://projecteuler.net/problem=10
Use:
compile using Rustc or Cargo, than simply run the
compiled file.
----------------------------------------------------------
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.