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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e6ff39dc211604d77374fdc6e9b4009cf76ba3f4 | Rust | Zazcallabah/aoc | /2019/6.rs | UTF-8 | 2,726 | 3.4375 | 3 | [] | no_license | use std::collections::HashMap;
type Map = HashMap<String,Stellar>;
struct Stellar {
name:String,
parent:String,
children:Vec<String>,
}
impl Stellar {
fn new(name:String) -> Stellar {
Stellar{name,children: Vec::new(),parent:"".to_owned()}
}
}
fn map(data:&str) -> Map {
let mut objects : Map = HashMap::new(... | true |
c280f3ce53aee37189fcaf10a2d1ded749364983 | Rust | Keruspe/adventofcode2020 | /src/bin/14.rs | UTF-8 | 2,869 | 3.28125 | 3 | [] | no_license | #![feature(str_split_once)]
static INPUT: &str = include_str!("./14.txt");
use std::str::FromStr;
use std::collections::BTreeMap;
#[derive(Debug)]
enum Instruction {
Mask(Mask),
Assign(usize, u64),
}
impl FromStr for Instruction {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
... | true |
ea04897320cee297be1fc84f7229ae573a87d758 | Rust | forkeith/ldraw.rs | /ldraw/src/library.rs | UTF-8 | 7,357 | 2.71875 | 3 | [] | no_license | use std::cell::RefCell;
use std::collections::HashMap;
use std::hash;
use std::ops::Deref;
use std::rc::Rc;
use serde::{Deserialize, Serialize};
use crate::document::{Document, MultipartDocument};
use crate::elements::PartReference;
use crate::AliasType;
use crate::NormalizedAlias;
#[derive(Serialize, Deserialize, C... | true |
00c86829d1715f45ad10e4d65f1ac0d58ffa4e34 | Rust | vain0x/text-position-rs | /src/position/utf16_position.rs | UTF-8 | 5,767 | 3.46875 | 3 | [
"CC0-1.0"
] | permissive | // LICENSE: CC0-1.0
use crate::TextPosition;
use std::{
cmp::Ordering,
fmt::{self, Debug, Display, Formatter},
ops::{Add, AddAssign},
};
/// Text position as (row, column) pair.
/// Column number (= length of the final line) is measured as number of UTF-16 code units (basically half of bytes).
/// Start f... | true |
0a0846fbf6939b342a0c00e911d6bec4dded354d | Rust | ratijas/mess | /mess-client/src/gui/_mvc.rs | UTF-8 | 20,957 | 3.3125 | 3 | [] | no_license | //! Concepts of view controller, view, model and delegate.
//!
//! View controller is stateful object capable of handling events (e.g. input),
//! it also can implement one or more delegate protocols. Composition of controllers
//! makes up a tree, which is an acyclic (non-recursive) directed graph. It makes it possibl... | true |
e65c75d2ac0a4e1ca931ed140b20e22cf2e7c50a | Rust | astro/rust-lpc43xx | /src/ethernet/mac_intr/mod.rs | UTF-8 | 2,796 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::MAC_INTR {
#[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 PMTR {
bits... | true |
d1634064e6add1be5ef39e4daf8235d167308caa | Rust | iotanbo/rust_playground | /BASICS/r03_ofbook/src/functions.rs | UTF-8 | 542 | 3.5 | 4 | [
"MIT"
] | permissive | //https://doc.rust-lang.org/book/ch03-03-how-functions-work.html
// * Statements do not return values
// * Expressions evaluate to something and return result as a value
// Example of function that returns a value
fn fourty_two() -> i32 {
// 42 is an expression, there is no semicolon after it.
// it is same a... | true |
ecc075f1156f32cfb34deb4551250b08c9d0b4ec | Rust | imerkle/shuttle-core | /src/memo.rs | UTF-8 | 1,904 | 3.65625 | 4 | [
"Apache-2.0"
] | permissive | use error::{Error, Result};
const MAX_MEMO_TEXT_LEN: usize = 28;
/// Memo attached to transactions.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Memo {
/// No memo
None,
/// Text Memo
Text(String),
/// Id Memo
Id(u64),
/// Hash Memo
Hash([u8; 32]),
/// Return Memo
Return([u8... | true |
109e57cfd3ea0f53c72ac2140fbc468caab9098a | Rust | codeworm96/hikari | /src/metal.rs | UTF-8 | 843 | 2.8125 | 3 | [] | no_license | use rand::prelude::*;
use crate::hitable::HitRecord;
use crate::material::Material;
use crate::ray::Ray;
use crate::util::random_in_unit_sphere;
use crate::vec3::{dot, Vec3};
pub struct Metal {
albedo: Vec3,
fuzz: f64,
}
impl Metal {
pub fn new(a: Vec3, f: f64) -> Metal {
Metal { albedo: a, fuzz:... | true |
c0f165ff016655d560faa79cf22937b8e13a7506 | Rust | EFanZh/LeetCode | /src/problem_0164_maximum_gap/radix_sort.rs | UTF-8 | 2,409 | 3.328125 | 3 | [] | no_license | pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
use std::mem;
impl Solution {
fn radix_sort(mut nums: Vec<i32>, max: i32) -> Vec<i32> {
// From the book Introduction to Algorithms, third edition, page 199.
... | true |
86d3fca5209baafac4730ec9523713e737c48172 | Rust | CloudSetDrive/game | /network/src/lib.rs | UTF-8 | 1,259 | 2.59375 | 3 | [] | no_license | extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate bincode;
mod packet;
// Reexports
pub use packet::ServerPacket as ServerPacket;
pub use packet::ClientPacket as ClientPacket;
use std::io;
use std::net::{UdpSocket, SocketAddr, IpAddr, Ipv4Addr};
use packet::Serialize;
pub struct ServerConn {
... | true |
21b0792e0f2c7c6195692c4d364251cabd6f467d | Rust | leandronsp/fun | /rust/dsa/tests/008-structs.rs | UTF-8 | 2,103 | 4.21875 | 4 | [] | no_license | // Struct allows to package together and name multiple related values
// in a meaningful group
// - Similar to Tuples, they both hold multiple related values of different types
// - Unlike Tuples, Structs hold a meaningful name
#[cfg(test)]
mod tests {
#[test]
fn structs() {
struct User {
ac... | true |
eb0b7353680c698b172313a02fd6803419b2c25f | Rust | meltinglava/gura-rs-parser | /tests/variables.rs | UTF-8 | 2,841 | 3.0625 | 3 | [
"MIT"
] | permissive | use gura::{
errors::{DuplicatedVariableError, ParseError, VariableNotDefinedError},
object,
parser::{parse, GuraType},
};
use std::env;
mod common;
fn get_expected() -> GuraType {
object! {
plain: 5,
in_array_middle: [1, 5, 3],
in_array_last: [1, 2, 5],
in_object: {
... | true |
fbb0e0220c0146b072bfbf56696da15d75f82e9a | Rust | gushernobindsme/rust-typical90 | /q-027/src/main.rs | UTF-8 | 650 | 3.03125 | 3 | [] | no_license | // -*- coding:utf-8-unix -*-
use proconio::input;
use std::collections::HashMap;
fn main() {
input! {
n: usize,
s: [String; n],
}
// (ユーザ名, 登録日) のマップを作る
// 降順にして一回だけ走査し、同じ値だった場合は上書きする
let mut map: HashMap<String, usize> = HashMap::new();
for i in (0..n).rev() {
map.ins... | true |
a23b0acbe92d6235225091e82d96f4c639c04309 | Rust | mneumann/ego | /ego-cli/src/main.rs | UTF-8 | 1,083 | 2.59375 | 3 | [
"MIT"
] | permissive | extern crate ego;
extern crate rand;
extern crate serde_json;
use ego::driver::{Config, SimulationConfig};
use std::env;
use std::fs::File;
use std::io::Read;
fn run_with_config(config: Config) {
let mut simulation =
SimulationConfig::new_from_config(config).create_simulation(Box::new(rand::thread_rng()))... | true |
f2fec6949d98746ba222afbdac943dcca8e7d886 | Rust | fossabot/improc | /viewer/src/app.rs | UTF-8 | 2,911 | 2.6875 | 3 | [] | no_license | use anyhow::Result;
use cgmath::Point3;
use image::DynamicImage;
use crate::{
image_manager::{Color, ImageManager},
presenter::Presenter,
viewer::Viewer,
};
const VIEWER_WINDOW_TITLE: &str = "Image Viewer";
pub struct App {
viewer: Viewer,
presenter: Presenter,
image_manager: ImageManager,
}... | true |
c0f6d60e9cb8fd20461ccbdcc16245925b3de9fd | Rust | ilovelll/learn-rust-by-example | /ch8-flow-control/src/main.rs | UTF-8 | 7,281 | 3.75 | 4 | [] | no_license | fn main() {
let mut counter = 0;
let result = loop {
counter += 1;
if counter == 10 {
break counter * 2; // return value with break
}
};
assert_eq!(result, 20);
let mut n = 1;
while n < 101 {
if n % 15 == 0 {
println!("fizzbuzz");
... | true |
109fbcf8a3aa417d55a019408e6eda3ce9d9eb6b | Rust | darayus/deuterium | /src/sql/select.rs | UTF-8 | 3,099 | 2.703125 | 3 | [
"MIT"
] | permissive | use from::{FromSelect};
use select_query::{
Select,
SelectQuery, RcSelectQuery,
SelectFor
};
use sql::{SqlContext, ToSql, QueryToSql};
use sql::value::{ToPredicateValue};
use sql::from::{FromToSql};
impl<T, L, M> FromToSql for FromSelect<T, L, M> {
fn to_from_sql(&self, ctx: &mut SqlContext) -> String... | true |
6e025ee88112de579910e16fe7613b4a5fb29ab6 | Rust | Gordon-F/rust-by-example-ru | /examples/hello/print/print.rs | UTF-8 | 2,422 | 3.84375 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | fn main() {
// `{}` автоматически будет заменено на
// аргументы. Они будут преобразованы в строку.
println!("{} days", 31);
// Без суффиксов, 31 является i32. Можно изменить тип 31,
// используя суффикс.
// Существует множество способов работы с форматированным выводом. Можно указать
// п... | true |
89d6b2e460aa2e9676da77beb3a1978f8835e9ea | Rust | seansfkelley/rt-rs | /src/core/color.rs | UTF-8 | 4,673 | 3.609375 | 4 | [] | no_license | use std::ops::{ Add, Sub, Div, Mul, AddAssign, SubAssign, DivAssign, MulAssign };
use std::fmt::{ Display, Debug, Formatter, Result };
use std::f64::{ INFINITY, NEG_INFINITY };
use math::*;
#[derive(Clone, Copy)]
pub struct Color {
pub r: f64,
pub g: f64,
pub b: f64,
}
impl Color {
pub const BLACK: Co... | true |
c102cb418a16899bb75e0c789899c383f0bde59c | Rust | renellc/rusty-chip | /src/chip8/instructions_test.rs | UTF-8 | 6,790 | 3.109375 | 3 | [] | no_license | #[cfg(test)]
mod instructions_parse_test {
use crate::chip8::instructions::Instruction;
use std::convert::TryFrom;
#[test]
fn try_into_test_1nnn() {
let opcode = 0x1FA3;
let instr = Instruction::try_from(opcode).unwrap();
if let Instruction::FlowJump(addr) = instr {
... | true |
cd6d8c9a03e475ff99551bce643df11f290e94f4 | Rust | dannymcgee/lox | /packages/vm/src/vector/mod.rs | UTF-8 | 2,053 | 2.71875 | 3 | [
"MIT"
] | permissive | use std::{
alloc::{self, Layout},
mem,
ptr::{self, NonNull},
};
mod debug;
mod into_iter;
mod iter;
pub use into_iter::IntoIter;
#[cfg(test)]
mod tests;
#[macro_export]
macro_rules! vector {
[] => {
$crate::vector::Vector::new()
};
[$($elem:expr),*$(,)?] => {{
let mut vec = $crate::vector::Vector::new();
... | true |
72bcc9f995aa8614aa79b8968086af5aabc04d26 | Rust | alcarney/iaith | /iaith/src/main.rs | UTF-8 | 382 | 2.578125 | 3 | [] | no_license | use iaith::brainf::Program;
use std::env;
use std::process;
fn main() {
let mut args = env::args();
args.next();
let mut prog = match args.next() {
Some(p) => Program::new(&p),
None => {
eprintln!("You must specify a program.");
process::exit(1);
}
};
... | true |
0b16389ab1a18f936c4a7a6d94602ec99faf96ae | Rust | PI-Victor/blog-api | /src/http/routes.rs | UTF-8 | 434 | 2.625 | 3 | [] | no_license | use crate::api::types::{DBConn, NewPost, NewUser};
use rocket_contrib::json::Json;
#[get("/", format = "json")]
pub fn get_posts(conn: DBConn) {}
#[get("/<id>", format = "json")]
pub fn get_post(id: usize) {}
#[post("/new", format = "application/json", data = "<post>")]
pub fn new_post(conn: DBConn, post: Json<NewPo... | true |
3d54a136ff31517000be949ad74bb4d5f8df6295 | Rust | cjkenn/tyr | /src/sym_tab.rs | UTF-8 | 1,003 | 3.734375 | 4 | [] | no_license | use std::collections::HashMap;
/// SymbolTable is used to help determine program
/// addresses to jump to when executing jump
/// instructions.
pub struct SymbolTable {
/// Hash table mapping a label name to an address in a program.
table: HashMap<String, usize>
}
impl SymbolTable {
pub fn new() -> Symbol... | true |
868d3909baf4499348232308963a3484320b025b | Rust | jiri/thesis-assembler | /src/grammar.rs | UTF-8 | 2,993 | 2.84375 | 3 | [] | no_license | use std::collections::HashMap;
pub type Label = String;
#[derive(Debug)]
pub struct Register(pub u8);
impl Register {
fn new(n: u8) -> Result<Register, &'static str> {
if n <= 15 {
Ok(Register(n))
} else {
Err("register index between 0 and 15")
}
}
}
#[derive(... | true |
4ff45a63561c33288e57b0315cad166ea38ba0a6 | Rust | xkikeg/rust-examples | /p003_simple_list_and_move.rs | UTF-8 | 659 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright (c) 2014 liquid_amber
// This file is distributed under MIT license.
// See LICENSE file.
enum SimpleList<T> {
Cons(T, Box<SimpleList<T>>),
Nil,
}
fn length<T>(xs: &SimpleList<T>) -> i32 {
match xs {
&SimpleList::Cons(_, ref ys) => 1 + length(ys),
&SimpleList::Nil => 0,
}
... | true |
73f1748a440882336310c7fc790a95c5572c8b8d | Rust | k-ymmt/splash | /src/main.rs | UTF-8 | 2,937 | 3.109375 | 3 | [
"MIT"
] | permissive | use termion::event::Key;
use termion::event::Event;
use termion::raw::{IntoRawMode, RawTerminal};
use termion::input::TermRead;
use termion::cursor::DetectCursorPos;
use std::io::{Write, Read, stdin, stdout, Stdin, Stdout, StdoutLock};
fn main() {
let stdin = stdin();
let stdin = stdin.lock();
let stdout =... | true |
a818c131defb5a142d8aa34283ddef4c723666b5 | Rust | rust-user-group-graz/05-data-structures | /examples/asmdump/src/main.rs | UTF-8 | 1,436 | 2.703125 | 3 | [] | no_license | #![feature(asm)]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn dump_stack() {
let nr_elements = 70;
for i in 0..nr_elements {
let offset = nr_elements - i - 1;
let mut result: u64;
unsafe {
asm!("movq %rsp, %rax
addq %rbx, %rax
... | true |
960a889e2c3fe7dc7e48433b6de5e1140121be09 | Rust | sheosi/lily | /common/src/audio/playdevice.rs | UTF-8 | 2,952 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | use std::io::Cursor;
use std::time::Duration;
use crate::audio::{Audio, AudioRaw, Data};
use crate::vars::MAX_SAMPLES_PER_SECOND;
use ogg_opus::decode;
use rodio::{source::Source, OutputStream, OutputStreamHandle, StreamError};
use thiserror::Error;
use tokio::time::sleep;
pub struct PlayDevice {
_stream: Output... | true |
a8f43db27eed0d249d450723e157c3dbe88c60bc | Rust | jlricon/advent-code-2019-rust | /src/bin/day_03_part2.rs | UTF-8 | 2,054 | 3.515625 | 4 | [] | no_license | use std::collections::HashSet;
use std::iter::FromIterator;
enum Directions {
U,
D,
R,
L,
}
struct Step {
dir: Directions,
num: u32,
}
#[derive(Debug, PartialEq, Hash, Eq)]
struct Point(i32, i32);
impl Point {
fn displace(&self, other: &Point) -> Point {
Point(self.0 + other.0, se... | true |
e85c270e1cac2e3ab5b72be3c98639556ff71ef2 | Rust | bfffs/bfffs | /bfffs-core/tests/cacheable_space.rs | UTF-8 | 17,706 | 2.515625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Measures the actual memory consumption of Cacheable implementors
//!
//! Can't use the standard test harness because we need to run single-threaded.
use bfffs_core::{
cache::{Cacheable, CacheRef},
ddml::DRP,
dml::{Compression, DML},
fs_tree::*,
idml::RidtEntry,
property::Property,
tree:... | true |
c2aff606cb7e660eddb2e3f105bc64e86fb0f059 | Rust | errord/weld | /weld/src/sir/optimizations/simplify_assignments.rs | UTF-8 | 4,339 | 3.484375 | 3 | [
"BSD-3-Clause"
] | permissive | //! An SIR pass that removes unnecessary assignments.
//!
//! This pass replaces assignment expressions that assign the same source to a particular target in
//! each basic block with the source directly. For example:
//!
//! ```sir
//! B1:
//! fn1_tmp__0 = x
//! jump B3
//! B2:
//! fn1_tmp__0 = x
//! jump ... | true |
bbd4feb063fbe62d7eb4179e7cdf434ed664c87e | Rust | mikeyhc/blog_os | /src/memory/mod.rs | UTF-8 | 4,295 | 2.671875 | 3 | [
"MIT"
] | permissive | pub use self::area_frame_allocator::AreaFrameAllocator;
use self::paging::{PhysicalAddress, Page};
pub use self::paging::test_paging;
pub use self::paging::remap_the_kernel;
use multiboot2::BootInformation;
use hole_list_allocator::{HEAP_START, HEAP_SIZE};
pub use self::stack_allocator::Stack;
mod area_frame_allocator... | true |
2c50cd2f4356c27676a64689aec54d834c84e341 | Rust | gavinzheng/rust-threshold-secret-sharing | /src/numtheory/fft.rs | UTF-8 | 8,702 | 2.6875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright (c) 2016 rust-threshold-secret-sharing developers
//
// 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. All files in the project carrying such notic... | true |
62704addc26bd89e01a15d8bc188aed7eaff20fb | Rust | kumo86/zemeroth | /zgui/src/lib.rs | UTF-8 | 29,570 | 2.765625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Tiny and opinionated GUI.
use std::{
cell::RefCell,
error::Error as StdError,
fmt::{self, Debug},
rc::Rc,
sync::mpsc::{channel, Receiver, Sender},
};
use gwg::{
graphics::{self, Color, Drawable, Point2, Rect, Vector2},
Context, GameError, GameResult,
};
use log::{info, trace};
pub con... | true |
0fea779aa8d40246612ba757f9d4a363598b0012 | Rust | tomvidm/rusty-cas | /src/numeric.rs | UTF-8 | 8,701 | 3.625 | 4 | [] | no_license | #![allow(dead_code)]
use std::fmt;
use std::ops::{Add, Sub, Mul, Div, Neg};
pub type ComplexType = f64;
pub type RealType = f64;
pub type IntegerType = i64;
// Numeric type
#[derive(Clone, Copy, PartialEq, PartialOrd)]
pub enum Numeric {
Real(RealType),
Complex(ComplexType),
Integer(IntegerType)
}
impl... | true |
3e43b66e8eac0d8be733d1663292aab37be3211d | Rust | LitxDev/freshfetch | /src/info/resolution.rs | UTF-8 | 11,488 | 2.65625 | 3 | [
"MIT"
] | permissive | use crate::mlua;
use crate::regex;
use crate::errors;
use crate::utils;
use super::kernel;
use std::env::{ var, vars };
use std::fs::{ read_to_string };
use std::path::{ Path };
use std::process::{ Command };
use regex::{ Regex };
use mlua::prelude::*;
use crate::{ Inject };
use utils::{ which::{ which } };
use ker... | true |
a751a28335768772de986655ff9009a8c12bb808 | Rust | sfackler/rust-postgres | /postgres-types/src/special.rs | UTF-8 | 3,024 | 3.203125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use bytes::BytesMut;
use postgres_protocol::types;
use std::error::Error;
use std::{i32, i64};
use crate::{FromSql, IsNull, ToSql, Type};
/// A wrapper that can be used to represent infinity with `Type::Date` types.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Date<T> {
/// Represents `infinity`, a date ... | true |
50dd63ef3d600159b414ec93b9c09b97713fefcd | Rust | hpolloni/xagima | /src/testing.rs | UTF-8 | 598 | 2.734375 | 3 | [
"MIT"
] | permissive | use core::panic::PanicInfo;
use crate::println;
pub fn runner(tests: &[&dyn Fn()]) {
println!("Running {} tests", tests.len());
for test in tests {
test();
}
success();
}
pub fn default_panic_handler(info: &PanicInfo) -> ! {
println!("[failed]\n");
println!("Error: {}\n", info);
f... | true |
ba606ac38a54e3624df4ad919ede2fda69dda863 | Rust | FyroxEngine/Fyrox | /src/scene/mesh/buffer.rs | UTF-8 | 52,281 | 3.59375 | 4 | [
"MIT"
] | permissive | //! Vertex buffer with dynamic layout. See [`VertexBuffer`] docs for more info and usage examples.
use crate::{
core::{
algebra::{Vector2, Vector3, Vector4},
arrayvec::ArrayVec,
byteorder::{ByteOrder, LittleEndian},
futures::io::Error,
math::TriangleDefinition,
visit... | true |
42a1a653c006b6c3580ad8bf08f14dd36d0cb874 | Rust | lightsofapollo/toml-json-rs | /src/tomljson/json_toml.rs | UTF-8 | 2,766 | 3.328125 | 3 | [] | no_license | use toml;
use rustc_serialize::json::{self, Json};
use std::io::{BufReader, Read};
use std::collections::BTreeMap;
pub struct JsonConverter;
impl JsonConverter {
pub fn new() -> JsonConverter {
JsonConverter
}
fn convert_json(&self, json: &json::Json) -> toml::Value {
match json {
... | true |
3e7c363e429ec961ebae27e3887041479226e4e9 | Rust | base0x10/Marzipan | /marzipan-core/src/emulators/generic_emulator/emulation_operations.rs | UTF-8 | 28,535 | 2.78125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use redcode::{CompleteInstruction, Modifier, Opcode};
use super::{
offset, operands::RegisterValues, processes::ProcessQueueSet, pspace,
};
use crate::{
emulator_core::{EmulatorError, EmulatorResult},
CoreAddr,
};
/// The results of operand evaluation and the core state required to emulation
/// an instru... | true |
db256a6f68c9cf98d0fada5f777c575053cc73ef | Rust | widforss/compiler | /src/ast/borrowchecker/util.rs | UTF-8 | 3,476 | 2.859375 | 3 | [] | no_license | use super::{Ast, BorrowError, ErrorKind, Expr, Lifetimes, Literal, State, UnOp, Value};
use std::collections::HashMap;
use std::collections::HashSet;
const LOCAL_LIFE: &'static str = "'!local";
pub fn borrow_expr<'a>(
expr: &'a Expr<'a>,
var_id: &mut u64,
ast: &'a Ast<'a>,
borrowstate: &mut State<(Vec... | true |
a9d7eb639a874a7d75543ebb47a183e89f2d13d3 | Rust | kulinsky/leetcode-problems | /array/single-number/main.rs | UTF-8 | 838 | 3.40625 | 3 | [] | no_license | // https://leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/549/
// Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.
// You must implement a solution with a linear runtime complexity and use only constant extra space.
//
// Example 1:
... | true |
86868905ea03a10e45494cb3e0579db3739f6bc1 | Rust | ksk001100/genetic_algorithm_rs | /src/main.rs | UTF-8 | 551 | 2.671875 | 3 | [] | no_license | mod ga;
use ga::*;
const GENERATION: i32 = 100;
fn main() {
let mut pop = Population::new(100, 10, 0.6, 0.2);
pop.evaluate();
println!("Generation : 0");
println!("Max : {}", pop.max().rank);
println!("Min : {}", pop.min().rank);
println!("-----------------------------");
for gen in 1..... | true |
e79fdd61cee0d191fdf17fbfc11a81297e7c1aa2 | Rust | icedland/iced | /src/rust/iced-x86-js/src/op_access.rs | UTF-8 | 1,301 | 2.671875 | 3 | [
"MIT"
] | permissive | // SPDX-License-Identifier: MIT
// Copyright (C) 2018-present iced project and contributors
use wasm_bindgen::prelude::*;
// GENERATOR-BEGIN: Enum
// ⚠️This was generated by GENERATOR!🦹♂️
/// Operand, register and memory access
#[wasm_bindgen]
#[derive(Copy, Clone)]
pub enum OpAccess {
/// Nothing is read and noth... | true |
bf7a0a5a8e1723fa48ba170b6ecd68a58de2d07a | Rust | bokuweb/docx-rs | /docx-core/src/reader/paragraph_property.rs | UTF-8 | 5,358 | 2.609375 | 3 | [
"MIT"
] | permissive | use std::io::Read;
use std::str::FromStr;
use xml::attribute::OwnedAttribute;
use xml::reader::{EventReader, XmlEvent};
use super::*;
use super::attributes::*;
use crate::types::*;
impl ElementReader for ParagraphProperty {
fn read<R: Read>(
r: &mut EventReader<R>,
attrs: &[OwnedAttribute],
... | true |
a08cc7c0a5beb4ba05cb9be6fc61856faa75b437 | Rust | RustPython/RustPython | /derive/src/lib.rs | UTF-8 | 3,847 | 2.609375 | 3 | [
"CC-BY-4.0",
"MIT"
] | permissive | #![recursion_limit = "128"]
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustPython/RustPython/main/logo.png")]
#![doc(html_root_url = "https://docs.rs/rustpython-derive/")]
use proc_macro::TokenStream;
use rustpython_derive_impl as derive_impl;
use syn::parse_macro_input;
#[proc_macro_derive(FromArgs, a... | true |
ffa3fed2c848861569a17e6593a887410600d132 | Rust | harryaskham/scrabrudo | /src/precompute.rs | UTF-8 | 8,776 | 2.890625 | 3 | [] | no_license | /// Utility for precomputing the Monte Carlo probabilities for each word in each situation.
// TODO: Can we get away without redefining the world?
#[macro_use]
extern crate log;
extern crate pretty_env_logger;
extern crate speculate;
#[macro_use]
extern crate maplit;
#[macro_use(c)]
extern crate cute;
#[macro_use]
exte... | true |
bcda2b05dc2a193388ca3fae1debdcc10d342345 | Rust | janpauldahlke/fhir-rs | /src/model/ValueSet_Compose.rs | UTF-8 | 9,306 | 3.109375 | 3 | [
"MIT"
] | permissive | #![allow(unused_imports, non_camel_case_types)]
use crate::model::Element::Element;
use crate::model::Extension::Extension;
use crate::model::ValueSet_Include::ValueSet_Include;
use serde_json::json;
use serde_json::value::Value;
use std::borrow::Cow;
/// A ValueSet resource instance specifies a set of codes drawn fr... | true |
0d199330fcb485be7244a0d635e9d617d435fd90 | Rust | filestar-project/rust-fil-proofs | /filecoin-proofs/tests/parampublish/prompts_to_publish.rs | UTF-8 | 3,163 | 2.71875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::collections::HashSet;
use std::iter::FromIterator;
use failure::Error as FailureError;
use storage_proofs::parameter_cache::CacheEntryMetadata;
use crate::parampublish::support::session::ParamPublishSessionBuilder;
use std::collections::btree_map::BTreeMap;
#[test]
fn ignores_files_unrecognized_extensions(... | true |
74be3b18bdf77edb869747b4f98443c225f75172 | Rust | colt-browning/integer-partitions | /src/lib.rs | UTF-8 | 5,404 | 3.5625 | 4 | [
"MIT"
] | permissive | //! Efficiently enumerate integer partitions.
//!
//! This is an implementation of a method described by
//! [Jerome Kelleher](http://jeromekelleher.net/generating-integer-partitions.html),
//! which takes a constant amount of time for each partition.
//!
//! # Examples
//!
//! ```
//! use integer_partitions::Partition... | true |
549f2b2c78f293bdfa9a897888fb70e3a4d95196 | Rust | huggingface/tokenizers | /tokenizers/src/models/unigram/trainer.rs | UTF-8 | 30,147 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | use crate::models::unigram::{lattice::Lattice, model::Unigram};
use crate::tokenizer::{AddedToken, Result, Trainer};
use crate::utils::parallelism::*;
use crate::utils::progress::{ProgressBar, ProgressStyle};
use log::debug;
use serde::{Deserialize, Serialize};
use std::cmp::Reverse;
use std::collections::{HashMap, Has... | true |
ab8e2ae0eedfa28b1c1db1516c16fd4a9c215c59 | Rust | ccdle12/Rust-Book-Notes | /20_webserver/hello/src/bin/main.rs | UTF-8 | 2,274 | 3.40625 | 3 | [] | no_license | use hello::ThreadPool;
use std::fs;
use std::io::prelude::*;
use std::net::TcpListener;
use std::net::TcpStream;
use std::thread;
use std::time::Duration;
fn main() {
let listener = TcpListener::bind("127.0.0.1:7878").expect("failed to bind to port 7878");
// Create a thread pool with 4 threads.
let pool =... | true |
23036d6ed3c03c21ee07c31b37ec3e8e528bc2d0 | Rust | Pomettini/streaming-stampede | /src/pokemons.rs | UTF-8 | 1,153 | 2.6875 | 3 | [
"MIT"
] | permissive | use constants::*;
use ggez::graphics::*;
use ggez::*;
use pokemon_sprite::*;
use pokemon_types::*;
pub struct Pokemon {
pub pokemon_type: PokemonType,
pub sprite: PokemonSprite,
pub position: Point2,
pub speed: f32,
pub isfake: bool,
}
impl Pokemon {
pub fn new(ctx: &mut Context, pokemon_type:... | true |
44140672a3d0981621e213fa817efcfb089201f2 | Rust | sam-ulrich1/hedera-sdk-rust | /examples/create_file.rs | UTF-8 | 1,925 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use failure::{format_err, Error};
use hedera::{Client, SecretKey, Status};
use std::{env, thread::sleep, time::Duration};
use std::str::FromStr;
#[tokio::main]
async fn main() -> Result<(), Error> {
pretty_env_logger::try_init()?;
// Operator is the account that sends the transaction to the network
// Thi... | true |
711d9d090467624317ce9713c4efedf8f9ed35bb | Rust | fee1-dead/moreiter | /src/lib.rs | UTF-8 | 1,583 | 3.359375 | 3 | [] | no_license |
pub enum ProcessResult<T> {
/// Represents a value that is either mapped or the original value.
Value(T),
Values(Box<dyn Iterator<Item = T>>),
Skip(usize),
}
pub struct Process<I, T, F> {
#[doc(hidden)]
__iter: Option<Box<dyn Iterator<Item = I>>>,
iter: T,
predicate: F
}
impl<I, T, F>... | true |
ed6849edc1c547caa81bb0fd02ecf288bc912755 | Rust | KamiD/cosmwasm | /packages/std/src/types.rs | UTF-8 | 4,057 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | use std::fmt;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::coins::Coin;
use crate::encoding::Binary;
// Added Eq and Hash to allow this to be a key in a HashMap (MockQuerier)
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema, Hash)]
pub struct HumanAddr(pu... | true |
1c07d765f08c355a2ba524331b434a99cfb2d30b | Rust | passchaos/zoxide | /src/subcommand/query.rs | UTF-8 | 3,346 | 3.125 | 3 | [
"MIT"
] | permissive | use crate::db::Dir;
use crate::fzf::Fzf;
use crate::util;
use anyhow::{bail, Context, Result};
use structopt::StructOpt;
use std::io::{self, Write};
use std::path::Path;
/// Search for a directory
#[derive(Debug, StructOpt)]
#[structopt()]
pub struct Query {
keywords: Vec<String>,
/// Opens an interactive s... | true |
0184c6a0af51420e0e4022fea0ce115847404250 | Rust | timjrobinson/rust-book | /collections/src/main.rs | UTF-8 | 5,833 | 3.625 | 4 | [] | no_license | use std::collections::{HashMap,HashSet};
fn vectors() {
let mut v: Vec<i32> = Vec::new();
v.push(5);
v.push(444);
println!("Vector item 1 is: {}", v[1]);
let v2 = vec![6,7,8,9];
let mut third: &i32 = &v2[2];
println!("The third element is {}", third);
third = &3;
println!("Afte... | true |
5c47760e304fd76bb2c732be042e6dfa62d2eb7d | Rust | osphea/zircon-rpi | /src/developer/ffx/config/src/heuristic_config.rs | UTF-8 | 1,575 | 2.8125 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {crate::api::ReadConfig, serde_json::Value, std::collections::HashMap};
pub(crate) type HeuristicFn = fn(key: &str) -> Option<Value>;
pub(crate) stru... | true |
077f7049a0fd169a16b69bcd6758eb17fc6084a8 | Rust | gitter-badger/rsmorphy | /src/container/decode/error.rs | UTF-8 | 517 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::num::ParseIntError;
use std::num::ParseFloatError;
#[derive(Debug, Clone, PartialEq)]
pub enum DecodeError {
UnexpectedEnd,
UnknownPartType,
DoesntMatch,
ParseIntError(ParseIntError),
ParseFloatError(ParseFloatError)
}
impl From<ParseIntError> for DecodeError {
fn from(e: ParseIntEr... | true |
d878d2b2fefdce16a97ac82268ef7d2c79246c38 | Rust | HectorPeeters/dyno | /src/backend/x86_backend.rs | UTF-8 | 7,151 | 2.953125 | 3 | [] | no_license | use crate::ast::{BinaryOperationType, Expression, Statement};
use crate::backend::Backend;
use crate::error::{DynoError, DynoResult};
use crate::types::{DynoType, DynoValue};
use std::fs::File;
use std::io::BufWriter;
use std::io::Write;
use std::process::Command;
use std::time::SystemTime;
const REG_NAMES: [&str; 4] ... | true |
76315f21d377a981c39dc2876d7477c564bf8c7a | Rust | vanam/rust2llvm | /examples/07_function.rs | UTF-8 | 353 | 3.59375 | 4 | [
"MIT"
] | permissive |
fn gcd(a: i32, b: i32) -> i32 {
// if as a expression and expression as a implicit return statement
if b == 0 {
a
} else {
gcd(b, a % b) // support for direct recursion
}
}
fn main() {
let a: i32 = 12;
let b: i32 = 90;
printf("GCD(%d, %d) = %d\n", a, b, gc... | true |
3a73cd9585e21ad0dd0e86d39df9ca7c69f3b01d | Rust | kubos/kubos | /libs/file-protocol/src/protocol.rs | UTF-8 | 29,532 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | //
// Copyright (C) 2018 Kubos Corporation
//
// 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 |
a847e3733ea55add4f035ba2db05a0f38f0f7b42 | Rust | arnohub/vertex | /src/sources/node/btrfs.rs | UTF-8 | 14,868 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::BTreeMap;
use event::{Metric, tags};
use super::{Error, ErrorContext, read_into, read_to_string};
use std::path::{Path, PathBuf};
const SECTOR_SIZE: u64 = 512;
/// LayoutUsage contains additional usage statistics for a disk layout
pub struct LayoutUsage {
used_bytes: u64,
total_bytes: u6... | true |
985d828cabaf96264727e59df95824d8adb553ad | Rust | rodrigorc/lemon_rust | /examples/example1/src/lexer.rs | UTF-8 | 849 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive |
use regex::Regex;
pub enum LexerAction<TOKEN> {
Ignore,
Action(Box<dyn Fn(&str) -> Option<TOKEN>>),
Token(Box<dyn Fn() -> TOKEN>),
}
pub struct Lexer<TOKEN> {
re : Vec<(Regex, LexerAction<TOKEN>)>,
}
impl<TOKEN> Lexer<TOKEN> {
pub fn new<I>(rules: I) -> Lexer<TOKEN>
where I : IntoIterato... | true |
28772a3a8657f24800e4e3f204f15748c00a5c23 | Rust | E-gy/try_all | /src/lib.rs | UTF-8 | 1,291 | 3.546875 | 4 | [
"MIT"
] | permissive | //! Rust iterator extensions to operate on `Result`s effectively.
//!
//! ## [`try_map_all`](crate::TryMapAll::try_map_all)
//! _and [`try_map_all_opt`](crate::TryMapAllOption::try_map_all_opt)_
//!
//! Applies a closure on all items of the iterator until one fails (or all succeed).
//!
//! ```rust
//! # use crate::try... | true |
7edfd14c2688fe23ad0508a3181d6f88e2147595 | Rust | bilalhusain/redis-rs | /src/redis/parser.rs | UTF-8 | 4,569 | 3.171875 | 3 | [
"BSD-3-Clause"
] | permissive | use std::str;
use std::io::Reader;
use std::str::from_utf8;
use enums::*;
pub struct Parser<T> {
iter: T,
}
pub struct ByteIterator<'a> {
pub reader: &'a mut Reader,
}
impl<T: Iterator<u8>> Parser<T> {
/// Creates a new parser from a character source iterator.
pub fn new(iter: T) -> Parser<T> {
... | true |
64c249be2b9d74bdeeddbc769c026a3e2762e3ee | Rust | Nereuxofficial/rust_move_gen | /src/mv_list/mod.rs | UTF-8 | 1,580 | 2.78125 | 3 | [
"MIT"
] | permissive | use bb::BB;
use castle::Castle;
use square::Square;
mod mv_counter;
mod mv_vec;
mod piece_square_table;
mod sorted_move_adder;
pub use self::mv_counter::MoveCounter;
pub use self::mv_vec::MoveVec;
pub use self::piece_square_table::PieceSquareTable;
pub use self::sorted_move_adder::{SortedMoveAdder, SortedMoveHeap, So... | true |
0c1adb54bb80499762f4125d2c651db42f1dee67 | Rust | comit-network/secp256kfun | /secp256kfun/tests/against_c_lib.rs | UTF-8 | 5,298 | 2.6875 | 3 | [
"0BSD"
] | permissive | #![allow(non_snake_case)]
#[cfg(not(target_arch = "wasm32"))]
mod test {
use secp256k1::{PublicKey, SecretKey};
use secp256kfun::{g, marker::*, op::double_mul, s, Scalar, G};
fn rand_32_bytes() -> [u8; 32] {
use rand::RngCore;
let mut bytes = [0u8; 32];
rand::thread_rng().fill_bytes... | true |
9597749e517753d728e57de123b712478ca8bf57 | Rust | gnzlbg/stdsimd | /coresimd/src/macros.rs | UTF-8 | 16,788 | 2.765625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Utility macros
macro_rules! define_ty {
($name:ident, $($elty:ident),+) => {
#[repr(simd)]
#[derive(Clone, Copy, Debug, PartialEq)]
#[allow(non_camel_case_types)]
pub struct $name($($elty),*);
}
}
macro_rules! define_ty_doc {
($name:ident, $($elty:ident),+ | $(#[$doc:me... | true |
8e1f212a45d7c390102855e56ddf5ccc55fc1b3b | Rust | FengchenX/orbtk-mirror | /crates/widgets/src/numeric_box.rs | UTF-8 | 9,733 | 3.1875 | 3 | [
"MIT"
] | permissive | use super::behaviors::MouseBehavior;
use crate::prelude::*;
use crate::shell::{Key, KeyEvent};
use core::f64::MAX;
use rust_decimal::prelude::*;
pub static ID_INPUT: &'static str = "numeric_box_input";
pub static ELEMENT_INPUT: &'static str = "numeric_box_input";
pub static ELEMENT_BTN: &'static str = "numeric_box_but... | true |
8fbc8ae7551d4499e6b0385491e32574f30f94b0 | Rust | bytesnake/hex | /cli/src/store.rs | UTF-8 | 2,832 | 2.671875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::slice;
use std::io::Read;
use std::fs::File;
use std::process::Command;
use std::path::Path;
use walkdir::WalkDir;
use id3::Tag;
use hex_database::{Track, Writer};
use hex_music_container::{Configuration, Container};
pub fn store(write: &Writer, path: &Path, data_path: &Path) {
let mut files = Vec::new()... | true |
74d8d5b196757ad9579d4ba65c40cd278da6b2e1 | Rust | sergei-romanenko/spsc | /spsc-lite-rust/src/advanced_process_tree_builder.rs | UTF-8 | 5,530 | 2.640625 | 3 | [] | no_license | use crate::algebra::*;
use crate::he::*;
use crate::language::*;
use crate::msg::*;
use crate::process_tree::*;
use crate::process_tree_builder::*;
use std::rc::Rc;
// Advanced Supercompiler with homeomorphic embedding and generalization
struct AdvancedBuildStep;
fn abstract_node(alpha: &RcNode, t: &RcTerm, subst: ... | true |
c954daee439a95ca484b67c68bccb5784af46498 | Rust | mdzik/hyperqueue | /crates/hyperqueue/src/common/manager/pbs.rs | UTF-8 | 3,174 | 2.90625 | 3 | [
"MIT"
] | permissive | use std::path::PathBuf;
use std::process::Command;
use std::str;
use std::time::Duration;
use anyhow::Context;
use serde_json::Value;
use crate::common::env::HQ_QSTAT_PATH;
use crate::common::manager::common::{format_duration, parse_hms_duration};
pub struct PbsContext {
pub qstat_path: PathBuf,
}
impl PbsConte... | true |
3c454dc1df02a4a0b8291cf530d044fd0cb7e944 | Rust | JHowell45/rust-practise | /chapter_3/data_types/src/main.rs | UTF-8 | 678 | 3.421875 | 3 | [
"MIT"
] | permissive | fn main() {
let x = 2.0; // f64
println!("x: {}", x);
let y: f32 = 3.0; // f32
println!("y: {}", y);
let tup: (i32, f64, u8) = (500, 6.4, 1);
let (x, y, z) = tup;
println!("The value of x is: {}", x);
println!("The value of y is: {}", y);
println!("The value of z is: {}", z);
let a = [1, 2, 3, 4, 5]... | true |
ae0f91a34fb084ed858206bb4ccf9ef09d8e926d | Rust | joaodelgado/rustyboy | /src/lib.rs | UTF-8 | 1,415 | 3 | 3 | [] | no_license | #![allow(clippy::verbose_bit_mask)]
mod cartridge;
mod cpu;
mod debugger;
mod errors;
pub mod game_boy;
use std::fs::File;
use std::io::prelude::*;
use errors::{Error, ErrorKind, Result};
pub struct Config {
pub rom_name: String,
}
impl Config {
pub fn new(mut args: std::env::Args) -> Result<Config> {
... | true |
bb53b64c47ecc703864dd813f536274193ec38da | Rust | peter50216/vim-simple-statusline | /rust-bin/src/nvim/asyncio.rs | UTF-8 | 1,071 | 2.5625 | 3 | [
"MIT"
] | permissive | use futures::Poll;
use std::io;
use tokio::io::{AsyncRead, AsyncWrite};
pub struct AsyncIO<R: AsyncRead, W: AsyncWrite> {
fin: R,
fout: W,
}
impl<R: AsyncRead, W: AsyncWrite> io::Read for AsyncIO<R, W> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.fin.read(buf)
}
}
impl<R: ... | true |
dd496e5f8b7e00fc605d616974836f71a8929d2d | Rust | GavinHwa/tarpc | /src/client.rs | UTF-8 | 4,408 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2016 Google Inc. All Rights Reserved.
//
// Licensed under the MIT License, <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
use Packet;
use futures::{Async, BoxFuture};
use futures::stream::Empty;
use std::fmt;
use ... | true |
2b04394dc91c8224241bacc9c00637ea192fd5ed | Rust | Yelp/casper | /casper-server/src/lua/utils.rs | UTF-8 | 1,142 | 3.078125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | use mlua::{Lua, Result, Table};
fn random(_: &Lua, upper_bound: Option<u32>) -> Result<u32> {
let n = rand::random::<u32>();
match upper_bound {
Some(upper_bound) => Ok(n % upper_bound),
None => Ok(n),
}
}
fn random_string(_: &Lua, (len, mode): (usize, Option<String>)) -> Result<String> {
... | true |
2fffb0b8c45800ee09811e5e007243e6bd628ca9 | Rust | ReinierMaas/microfacet | /src/lib.rs | UTF-8 | 2,974 | 3.0625 | 3 | [
"MIT"
] | permissive | extern crate cgmath;
extern crate rand;
use cgmath::InnerSpace;
use cgmath::Vector3;
use self::rand::Closed01;
#[inline]
pub fn microfacet_sample(normal: &Vector3<f32>
, view: &Vector3<f32>
, alpha: f32) -> Vector3<f32> {
let Closed01(r0) = rand::random::<Closed01<f3... | true |
a60fdb8a71f14477f88be6aeb9a80da76cf8a706 | Rust | teachteamnfp/libra | /secure/storage/src/tests/suite.rs | UTF-8 | 4,791 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{Error, Policy, Storage, Value};
use libra_crypto::{ed25519::Ed25519PrivateKey, Uniform};
use rand::{rngs::StdRng, SeedableRng};
const KEY_KEY: &str = "key";
const U64_KEY: &str = "u64";
/// This helper function checks var... | true |
b1a859b9a0870a38e6cb3dc3a799692f92bfc604 | Rust | imxrt-rs/imxrt-async-hal | /src/pit.rs | UTF-8 | 10,926 | 3.03125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Periodic interrupt timer (PIT) driver and futures
//!
//! The PIT timer channels are the most precise timers in the HAL. PIT timers run on the periodic clock
//! frequency.
//!
//! A single hardware PIT instance has four PIT channels. Use [`new`](PIT::new()) to acquire these four
//! channels.
//!
//! # Example
//!... | true |
c83e38dfc8b54cc54edabda5c77866796cad5d6e | Rust | onelson/destiny2-api-rs | /codegen/src/models/destiny_responses_destiny_profile_response.rs | UTF-8 | 10,841 | 2.609375 | 3 | [] | no_license | /*
* Bungie.Net API
*
* These endpoints constitute the functionality exposed by Bungie.net, both for more traditional website functionality and for connectivity to Bungie video games and their related functionality.
*
* OpenAPI spec version: 2.0.0
* Contact: support@bungie.com
* Generated by: https://github.com... | true |
bc9e72c397c00dde831d0e917e789cfbefd42860 | Rust | pratik2709/learn-rust | /iterators/src/main.rs | UTF-8 | 1,422 | 3.703125 | 4 | [] | no_license | fn main() {
let v1 = vec![1,2,3];
let v1_iter = v1.iter();
println!("{:?}", v1_iter);
for v in v1_iter{
println!("{}", v)
}
let sumof:i32 = v1.iter().sum();
let t:Vec<_> = v1.iter().map(|x| x+1).collect();
println!("{:?}", t);
shoe_main();
println!("{:?}",Counter::new());
let mut c = Counter... | true |
a1ee3a41462e40e5f5844eeca8d8c137b7b51d6e | Rust | rune-rs/rune | /crates/rune/src/parse.rs | UTF-8 | 1,151 | 2.734375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Parsing utilities for Rune.
mod expectation;
mod id;
mod lexer;
mod opaque;
mod parse;
mod parser;
mod peek;
mod resolve;
pub use self::expectation::Expectation;
pub(crate) use self::expectation::IntoExpectation;
pub use self::id::{Id, NonZeroId};
pub(crate) use self::lexer::{Lexer, LexerMode};
pub(crate) use sel... | true |
55440e50b8e931b22f53753acdd621fff454c47f | Rust | im-0/log4rs-syslog | /src/file.rs | UTF-8 | 3,483 | 2.671875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #![forbid(unsafe_code)]
use std;
use libc;
use log;
use log4rs;
use syslog;
#[derive(Deserialize)]
struct SyslogAppenderOpenlogConfig {
ident: String,
option: syslog::LogOption,
facility: syslog::Facility,
}
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize)]
#[allow(non_camel_case_types)]
enum... | true |
f263f9002d1fa6a2d4c9c710882b4c8ae9fc8870 | Rust | CurryPseudo/curry-pbrt | /src/material/bxdf/mod.rs | UTF-8 | 9,564 | 2.65625 | 3 | [] | no_license | mod lambertian;
mod microfacet;
mod oren_nayar;
mod specular;
use crate::*;
pub use lambertian::*;
pub use microfacet::*;
pub use oren_nayar::*;
pub use specular::*;
use std::sync::Arc;
pub enum BxDFType {
Delta,
Reflect,
Transmit,
}
pub trait BxDF {
fn f(&self, wo: &Vector3f, wi: &Vector3f) -> Option... | true |
ef9dcb84c89c6aea0966344418da37b8988507ea | Rust | Rowmance/Chip8 | /src/keypad.rs | UTF-8 | 3,394 | 3.53125 | 4 | [] | no_license | use sdl2::keyboard::Keycode;
use std::mem::discriminant;
/// The keymap to use.
pub enum KeypadSetting {
/// DVORAK bindings.
DVORAK,
/// Qwerty Bindings.
QWERTY,
}
/// Represents a keypad.
pub struct Keypad {
/// The state of the 16 keys.
///
/// These have the following layout:
/// ... | true |
ef7d25e4aa95421e665bec9244c1a47e6f16395e | Rust | bvdvecht/cqc | /tests/request.rs | UTF-8 | 13,694 | 2.5625 | 3 | [
"MIT"
] | permissive | extern crate cqc;
#[cfg(test)]
mod request {
use cqc::builder::{Client, RemoteId};
use cqc::hdr::*;
use cqc::{Decoder, Encoder, Request};
macro_rules! get_byte_16 {
($value:expr, $byte:expr) => {
($value >> ((1 - $byte) * 8)) as u8
};
}
macro_rules! get_byte_32 {
... | true |
7716c6e378e06f3471b122aa8f888291b3eba6b6 | Rust | SergiusIW/collider-rs | /src/core/dur_hitbox/mod.rs | UTF-8 | 9,555 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2016-2018 Matthew D. Michelotti
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ... | true |
337c5a1bca6379fe27c2c523275fb14d679014ec | Rust | zevstravitz/Poker | /rust/src/cluster.rs | UTF-8 | 1,369 | 2.859375 | 3 | [] | no_license | use crate::card_utils;
use ndarray::Array;
use rand::prelude::SliceRandom;
use rand::thread_rng;
use std::collections::HashMap;
// Cluster hands based on the second moment of the equity distribution, aka E[HS^2].
// This approach is much faster but becomes inferior for larger abstractions.
// However, it may be suffic... | true |
0f1f32842d0eb740f348f5464fcbd90ebcf398e8 | Rust | conradlo/rusty-leetcode | /src/_0105_construct_binary_tree_from_preorder_and_inorder_traversal.rs | UTF-8 | 4,275 | 3.28125 | 3 | [] | no_license | /*
* @lc app=leetcode id=105 lang=rust
*
* [105] Construct Binary Tree from Preorder and Inorder Traversal
*/
// @lc code=start
// 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... | true |
ea92291d9de1ed3af764c31133cd5a2293b71128 | Rust | utilForever/BOJ | /Rust/15593 - Lifeguards (Bronze).rs | UTF-8 | 1,742 | 3.0625 | 3 | [
"MIT"
] | permissive | use io::Write;
use std::{io, str};
pub struct UnsafeScanner<R> {
reader: R,
buf_str: Vec<u8>,
buf_iter: str::SplitAsciiWhitespace<'static>,
}
impl<R: io::BufRead> UnsafeScanner<R> {
pub fn new(reader: R) -> Self {
Self {
reader,
buf_str: vec![],
buf_iter: ""... | true |
f58370df4357743ae787df32d2bade6f9540cf3b | Rust | thepowersgang/rust_os | /Kernel/Modules/gui/input/mod.rs | UTF-8 | 11,799 | 2.65625 | 3 | [
"BSD-2-Clause"
] | permissive | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Core/gui/input/mod.rs
//! GUI input managment
#[allow(unused_imports)]
use kernel::prelude::*;
use self::keyboard::KeyCode;
use core::sync::atomic::{Ordering,AtomicUsize,AtomicU8};
use kernel::sync::Mutex;
pub mod keyboard;
pub mod mouse;
#[derive(Debug)]
p... | true |
61c482ebd8b981fd0c8642599c18cb54f511ae24 | Rust | leandrosilva/wikipedia_roots | /src/main.rs | UTF-8 | 4,081 | 3.234375 | 3 | [] | no_license | use std::env;
use reqwest;
use scraper::{Html, Selector};
use std::thread;
use std::time::Duration;
use url::Url;
enum CrawlState {
Found,
Continue,
MaxSteps,
Loop,
}
fn get_base_url(url: &String) -> Url {
let mut url_obj = Url::parse(url).unwrap();
match url_obj.path_segments_mut() {
... | true |
f385eddea39a368644160bb29a291b568202ad9f | Rust | ivfranco/notes | /ostep/chapter_31/semaphore/src/bin/mutex_nostarve.rs | UTF-8 | 3,743 | 3.140625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | use std::{
cell::UnsafeCell,
collections::HashMap,
env::{self, Args},
fmt::Display,
ops::{Deref, DerefMut},
process,
str::FromStr,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
thread,
};
use semaphore::Semaphore;
fn main() {
let mut args = env::args();
... | true |
049ad47b18b9c86a73c32ffc45c77d2553b66af7 | Rust | strelec/DPLL-with-Rust | /src/solver/clause.rs | UTF-8 | 693 | 2.859375 | 3 | [] | no_license | extern crate bit_set;
use self::bit_set::BitSet;
pub type Set = BitSet;
pub type Bag = Vec<usize>;
pub struct Clause {
pub t: Bag,
pub f: Bag
}
impl Clause {
pub fn eval(&self, t: &Set, f: &Set) -> bool {
self.t.iter().any( |&v| t.contains(v) ) ||
self.f.iter().any( |&v| f.contains(v) )
}
pub fn eval_comp... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.