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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cad34b015e7aff84b190970bf3f7cfd2d356ab6b | Rust | lancelot96/information_theory | /assignments/assignment_big/源代码/src/helper.rs | UTF-8 | 3,403 | 3.015625 | 3 | [] | no_license | use std::{
cell::RefCell,
cmp::Ordering,
collections::{BTreeMap, HashMap},
fmt,
fs::{File, OpenOptions},
io::prelude::*,
path::Path,
rc::Rc,
};
use base_custom::BaseCustom;
use failure::Error;
#[derive(Debug)]
pub struct TreeNode {
pub label: char,
pub p: f64,
pub coding: O... | true |
aba14424ff648e2461cb81d15b2756b673ecfb2c | Rust | bytel0rd/landblock-chain | /src/utils.rs | UTF-8 | 887 | 3.53125 | 4 | [] | no_license | #[derive(Debug, Clone, Copy)]
pub enum ErrorLevel {
Internal,
External,
}
#[derive(Debug, Clone)]
pub struct Error {
message: String,
error_level: ErrorLevel
}
impl Error {
pub fn from_message(message: String) -> Self {
Error {
message,
error_level: ErrorLevel::... | true |
a8dfe6a3c286358c2f00b48d05694c2e798a1c06 | Rust | abhijeetbhagat/boa | /boa/src/builtins/value/operations.rs | UTF-8 | 4,694 | 3.53125 | 4 | [
"Unlicense",
"MIT"
] | permissive | use super::*;
impl Add for Value {
type Output = Self;
fn add(self, other: Self) -> Self {
match (self.data(), other.data()) {
(ValueData::String(ref s), ref o) => {
Self::string(format!("{}{}", s.clone(), &o.to_string()))
}
(ValueData::BigInt(ref n1)... | true |
192a62ff36c10808274a2383fd20533a8e941b23 | Rust | grzi/Voxpire-old-project | /src/engines/terrain/bloc.rs | UTF-8 | 482 | 2.65625 | 3 | [] | no_license | use crate::utilities::geometry::coordinates::Coordinates;
use crate::engines::blocs::bloc_type::BlocType;
pub const BLOC_HEIGHT : f32 = 1.0;
pub const BLOC_WIDTH : f32 = 1.0;
#[derive(Debug)]
pub struct Bloc {
coordinates: Coordinates,
bloc_type: BlocType,
}
impl Bloc {
pub fn new(coordinates : Coordinat... | true |
4bb845b83d40d7c4efac18d6884c165886c70405 | Rust | Lapz/tox-rewrite | /semant/src/ty.rs | UTF-8 | 3,161 | 3.40625 | 3 | [] | no_license | use crate::hir;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct TypeVar(pub u32);
/// A unique identifier that is used to distinguish to structs with the same fields
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Unique(pub u32);
static mut TYPEVAR_COUNT: u32 = 0;
static mut UNIQUE_COUNT: u32 = 0;... | true |
4903ab21cab2c0a9c94b5119128857f9a0109065 | Rust | daveyarwood/libmusictheory | /src/note.rs | UTF-8 | 7,329 | 3.578125 | 4 | [] | no_license | use regex::Regex;
use std::iter::repeat;
pub struct Note {
letter: char,
// a positive or negative number representing number of semitones up/down
accidentals: isize,
octave: isize
}
fn semitones_from_c(letter: char) -> isize {
match letter {
'C' => 0,
'D' => 2,
'E' => 4,
... | true |
0da1a4a642bdf50dbdf069a2ae7215b0b255740b | Rust | abomb4/rust-five | /src/game/mod.rs | UTF-8 | 12,425 | 3.28125 | 3 | [
"MIT"
] | permissive | use game::PieceType::BLACK;
use game::PieceType::WHITE;
use game::players::ai::IdiotAi;
use self::board::Board;
use self::coord::CoordinationFlat;
use self::players::LocalHumanPlayer;
use self::players::Player;
use std::char;
use std::fmt;
mod board;
mod players;
mod coord {
use std::fmt;
/// Define coordina... | true |
c83fe6ed169aec6929fca1c15b38d59057137ba6 | Rust | rusty-ecma/rusty-ecma-book | /console_logify/src/main.rs | UTF-8 | 9,940 | 2.65625 | 3 | [] | no_license | use ressa::Parser;
use resw::Writer;
use resast::prelude::*;
use std::{
fs::{
read_to_string,
File
},
io::BufWriter,
};
fn main() {
let mut args = ::std::env::args();
let _ = args.next();
let file_name = args
.next()
.unwrap_or(String::from("./examples/insert_lo... | true |
2b1d84bfb84b70ad0acc5192c2f4484e406ae4c0 | Rust | dplewis/deno | /core/normalize_path.rs | UTF-8 | 1,124 | 2.75 | 3 | [
"MIT"
] | permissive | // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
use std::path::Component;
use std::path::Path;
use std::path::PathBuf;
/// Normalize all intermediate components of the path (ie. remove "./" and "../" components).
/// Similar to `fs::canonicalize()` but doesn't resolve symlinks.
///
/// Take... | true |
4f086cc781696a6745fce9a36ff86fbef69259dc | Rust | fralken/ray-tracing-the-next-week | /src/bvh.rs | UTF-8 | 3,317 | 3 | 3 | [] | no_license | use std::f32;
use std::cmp::Ordering;
use crate::ray::Ray;
use crate::hitable::{Hitable, HitRecord};
use crate::aabb;
use crate::aabb::AABB;
enum BVHNode {
Branch { left: Box<BVH>, right: Box<BVH> },
Leaf(Box<dyn Hitable>)
}
pub struct BVH {
tree: BVHNode,
bbox: AABB
}
impl BVH {
pub fn new(mut h... | true |
8996cd0fe5ee8543c3ee59d76cbdcb532bb1a5da | Rust | bascarsija/advent_of_code_2019 | /day02/src/bin/part2.rs | UTF-8 | 900 | 2.671875 | 3 | [] | no_license | use day02::intcode;
fn main() {
let input = intcode::input::input_op_codes();
'TOP: for noun in 0..100 {
for verb in 0..100 {
let mut op_codes = input.clone();
let op_codes = op_codes.as_mut_slice();
intcode::replace_at_pos(op_codes, 1, noun);
intcode::... | true |
f83f94812f762bb6c65b0ac6deff6d0a6fb56717 | Rust | muzudho/kifuwarabe2020-wcsodr1 | /src/law/cryptographic.rs | UTF-8 | 1,195 | 3.296875 | 3 | [
"MIT"
] | permissive | //!
//! なんか難しいやつはここだぜ☆(^~^)
//!
use crate::cosmic::smart::square::AbsoluteAddress2D;
/// ハッシュ値を作る
pub fn push_sq_to_hash(hash: u64, square: Option<&AbsoluteAddress2D>) -> u64 {
// 0筋とか 0段とか 使ってないが、そのまま足す。
// 0~100の101升と、ちょいなんで、128(=2^7) あれば十分
(hash << 7)
+ if let Some(square_val) = square {
... | true |
3b818ed184cc8e35c7432f7207b2b17038948d71 | Rust | FeanorTheElf/Parser | /src/analysis/topological_sort.rs | UTF-8 | 4,065 | 3.046875 | 3 | [] | no_license | use super::super::language::prelude::*;
use super::scope::ScopeStack;
use super::super::util::ref_eq::Ptr;
use std::hash::Hash;
use std::collections::{HashSet, HashMap};
///
/// Calculates a topological sorting of a directed, acyclic graph. The given iterator over
/// nodes must yield at least a set of graph nodes f... | true |
b0d2ff485a2f9e5f403b9b3eac30c1bf5c4c1dce | Rust | vitvakatu/asteroids | /src/collide.rs | UTF-8 | 194 | 2.71875 | 3 | [] | no_license | use euler::Vec2;
pub fn collide(pos1: Vec2, r1: f32, pos2: Vec2, r2: f32) -> bool {
let distance = (pos1 - pos2).squared_length();
let radiuses = (r1 + r2).powf(2.0);
distance <= radiuses
}
| true |
6c055f19e67650f8ea34e11997eb37120b99cb33 | Rust | sigp/lighthouse | /common/unused_port/src/lib.rs | UTF-8 | 3,239 | 3 | 3 | [
"Apache-2.0"
] | permissive | use lazy_static::lazy_static;
use lru_cache::LRUTimeCache;
use parking_lot::Mutex;
use std::net::{SocketAddr, TcpListener, UdpSocket};
use std::time::Duration;
#[derive(Copy, Clone)]
pub enum Transport {
Tcp,
Udp,
}
#[derive(Copy, Clone)]
pub enum IpVersion {
Ipv4,
Ipv6,
}
pub const CACHED_PORTS_TTL:... | true |
92a1ab5c6d18ec79367c3fae8df74d9f92b311c8 | Rust | iCodeIN/item_identifier | /src/item_identifier.rs | UTF-8 | 430 | 2.796875 | 3 | [] | no_license | pub use struct_name_derive::*;
pub trait ItemIdentifier {
const IDENTIFIER: &'static str;
fn identifier(&self) -> &'static str {
Self::IDENTIFIER
}
}
mod test {
use super::ItemIdentifier;
struct Foobar {}
impl ItemIdentifier for Foobar {
const IDENTIFIER: &'static str = "Foob... | true |
515dfa1079a13d64f1eb1a1bef3c20dc3d7772c7 | Rust | imkgerC/uni-theo2-hashset | /src/logging.rs | UTF-8 | 6,064 | 3.0625 | 3 | [] | no_license | //! Module for helper logging functions
//!
//! This module contains all functions for writing output
use gnuplot::{AxesCommon, Caption, Figure, Graph};
use std::fs::OpenOptions;
use std::io::Write;
/// Print a simple header for the table
///
/// # Example
/// Name | 50% | 90% | 95% | 100%
pub fn print_header(... | true |
e38e7cf66de651c6880bf402de4429bf76d6e103 | Rust | defgenx/adventofcode | /2020/2/b/b.rs | UTF-8 | 1,564 | 2.890625 | 3 | [] | no_license | use std::collections::HashMap;
fn main() {
b();
}
fn b() {
let list = advent_of_code::file::read_stream();
let mut map_rows: Vec<HashMap<&str, String>> = Vec::new();
for line in list {
let mut map_row = HashMap::new();
let split_line = line.as_ref().unwrap().split_whitespace();
... | true |
4845c25a3659a8abd2f1834e2c9445ff0a182952 | Rust | ds84182/pomelo | /kernel/src/memory/phys.rs | UTF-8 | 834 | 3.09375 | 3 | [
"MIT"
] | permissive | use super::{Memory, PageSlice, Page};
pub struct PhysicalMemory(Box<[Page]>);
impl PhysicalMemory {
pub fn new(pages: u32) -> PhysicalMemory {
let mut vec = Vec::<Page>::with_capacity(pages as usize);
unsafe { vec.set_len(pages as usize); }
unsafe {
std::ptr::write_bytes(vec.as... | true |
6e99f7383f7c8a0263e1c55cb1ef67a9b1d3e5af | Rust | DirtGrubDylan/advent_of_code_2106 | /rust/day_8/src/main.rs | UTF-8 | 475 | 2.828125 | 3 | [
"MIT"
] | permissive | extern crate libday_8;
use std::env;
use libday_8::Screen;
fn main() {
let arguments: Vec<String> = env::args().collect();
let mut screen = Screen::new(50, 6);
let instructions = libday_8::load_instructions_from(&arguments[1]).unwrap();
for instruction in instructions {
libday_8::interpret_i... | true |
d53aff0b1710fa9018cf65c18084b0e94665c9a7 | Rust | IQ-SCM/gh-stack | /src/util.rs | UTF-8 | 366 | 3.125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | use dialoguer::Input;
pub fn loop_until_confirm(prompt: &str) {
let prompt = format!("{} Type 'yes' to continue", prompt);
loop {
let result = Input::<String>::new()
.with_prompt(&prompt)
.interact()
.unwrap();
match &result[..] {
"yes" => return,... | true |
98a44ea1530e310ffd16f3ff7dd4b3f39d86f0cd | Rust | Connicpu/AoC2019 | /src/bin/day15.rs | UTF-8 | 4,716 | 2.71875 | 3 | [] | no_license | use aoc2019::intcode::{Cpu, CpuResult::*};
use std::collections::HashMap;
use std::ops::{Add, Sub};
use pathfinding::prelude::dijkstra;
static INPUT: &str = include_str!("input/day15.txt");
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Default)]
struct Vec2 {
x: i32,
y: i32,
}
impl Vec2 {
fn signum... | true |
9c986e85a7cf920469eccd0e2b1e52eb8446f9c2 | Rust | marcy-terui/specinfra-1 | /src/platform/linux/redhat.rs | UTF-8 | 1,949 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::prelude::*;
use backend::Backend;
use platform::platform::Platform;
use provider::Providers;
use provider::file;
use provider::file::FileProvider;
use provider::service;
use provider::service::ServiceProvider;
#[derive(Clone, Debug)]
pub struct RedHat {
name: String,
release: S... | true |
d192c55408126e8998df500abdc6320bba98d23a | Rust | EmbarkStudios/rust-gpu | /tests/ui/glam/mat3_vec3_multiply.rs | UTF-8 | 239 | 2.671875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Tests multiplying a `Mat3` by a `Vec3`.
// build-pass
use spirv_std::spirv;
#[spirv(fragment)]
pub fn main(input: glam::Mat3, output: &mut glam::Vec3) {
let vector = input * glam::Vec3::new(1.0, 2.0, 3.0);
*output = vector;
}
| true |
1ff631426f1a9249641db48835566e1da2119f69 | Rust | michaelfairley/adventofcode2016 | /src/bin/1b.rs | UTF-8 | 1,324 | 2.75 | 3 | [] | no_license | use std::collections::HashSet;
const INPUT: &'static str = "L5, R1, R3, L4, R3, R1, L3, L2, R3, L5, L1, L2, R5, L1, R5, R1, L4, R1, R3, L4, L1, R2, R5, R3, R1, R1, L1, R1, L1, L2, L1, R2, L5, L188, L4, R1, R4, L3, R47, R1, L1, R77, R5, L2, R1, L2, R4, L5, L1, R3, R187, L4, L3, L3, R2, L3, L5, L4, L4, R1, R5, L4, L3, L... | true |
93c9033b4b0f52fd1752a8252878e5bd46c83ec8 | Rust | exercism/rust | /exercises/practice/custom-set/tests/custom-set.rs | UTF-8 | 7,468 | 3.546875 | 4 | [
"MIT"
] | permissive | use custom_set::*;
#[test]
fn sets_with_no_elements_are_empty() {
let set: CustomSet<()> = CustomSet::new(&[]);
assert!(set.is_empty());
}
#[test]
#[ignore]
fn sets_with_elements_are_not_empty() {
let set = CustomSet::new(&[1]);
assert!(!set.is_empty());
}
#[test]
#[ignore]
fn nothing_is_contained_in... | true |
8132cd96bd5fd702182935eea763b49dcb1e304a | Rust | reynoldsbd/gd32vf103-samples | /src/echo.rs | UTF-8 | 3,146 | 2.96875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Implements a trivial serial "console" that echoes text back at the user
#![no_std]
#![no_main]
extern crate panic_halt;
use core::fmt::Write;
use core::str::Utf8Error;
use embedded_hal::serial::Read;
use gd32vf103_pac::Peripherals;
use gd32vf103xx_hal::afio::AfioExt;
use gd32vf103xx_hal::gpio::GpioExt;
use gd3... | true |
12ac9fcefa38bbb78a94acb19cc46af9414e9ce6 | Rust | johnnyeric/glot-run2 | /src/glot_run/api/languages/list_versions.rs | UTF-8 | 1,712 | 2.546875 | 3 | [
"MIT"
] | permissive | use crate::glot_run::config;
use crate::glot_run::api;
use crate::glot_run::language;
use crate::glot_run::datastore;
use crate::glot_run::file;
use crate::glot_run::util;
#[derive(Debug, Eq, PartialEq, serde::Serialize)]
pub struct Language {
version: String,
url: String,
}
pub fn handle(config: &config::C... | true |
34a02dc4014e8e34407265fac530ef0eead6eb3f | Rust | mart368b/foreignc | /foreignc_template/src/derived_input.rs | UTF-8 | 3,904 | 2.78125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::*;
use std::collections::hash_map::DefaultHasher;
#[allow(unused_imports)]
use std::fs::{create_dir, read_dir, read_to_string, remove_file, File, OpenOptions};
use std::hash::{Hash, Hasher};
#[allow(unused_imports)]
use std::io::Write;
use std::path::{Path, PathBuf};
use std::sync::Once;
static INIT: Once =... | true |
d48448b1e64411269abc62f8e8ae4faaff240a76 | Rust | danbev/learning-rust | /snippets/src/types.rs | UTF-8 | 263 | 2.984375 | 3 | [] | no_license |
#[cfg(test)]
mod tests {
#[test]
fn types_test() {
let nr: i32 = 10;
let nr2 = &10;
println!("nr = {} {:p}", nr, &nr);
println!("nr2 = {} {:p}", nr2, nr2);
assert_eq!(nr, 10);
assert_eq!(nr2, &10);
}
}
| true |
efa685aef7511a225de1b47f07d21a75dc1e07aa | Rust | tib888/room-pill | /src/display.rs | UTF-8 | 2,816 | 3.109375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use crate::timing::{Duration, Seconds, WeekTime};
use onewire::temperature::Temperature;
static WEEKDAYS: [&[u8]; 7] = [
b"Hetfo",
b"Kedd",
b"Szerda",
b"Csutortok",
b"Pentek",
b"Szombat",
b"Vasarnap",
];
pub fn fmt_weekday(n: u8) -> &'static [u8] {
//assert!(n < 7);
&(WEEKDAYS[n as... | true |
186a4d881aec9f98f65f44317855c771224a973d | Rust | Riey/pe-parser | /src/lib.rs | UTF-8 | 3,443 | 2.546875 | 3 | [] | no_license | #![recursion_limit = "128"]
#[macro_use]
extern crate nom;
#[macro_use]
extern crate enum_primitive;
#[macro_use]
extern crate exe;
extern crate libc;
#[allow(unused_macros)]
use libc::{c_void, size_t, uint8_t};
pub mod enums;
pub use enums::*;
pub mod structures;
pub use structures::*;
pub mod parsers;
pub use pa... | true |
c69fd1106ec49dcb5e99a233cd823816ce7b42d5 | Rust | kodsnack/advent_of_code_2019 | /johan-oelrich-rust/wire/src/lib.rs | UTF-8 | 8,454 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::{HashMap, HashSet};
extern crate loader;
#[derive(Hash, PartialEq, Eq, Clone, Copy, Debug, PartialOrd, Ord)]
struct Point(i64, i64);
impl Point {
#[cfg(test)]
fn new(x: i64, y: i64) -> Point {
Point(x, y)
}
fn zero() -> Point {
Point(0, 0)
}
fn visited_points(&self, step: usiz... | true |
d29c4580cc4b7aacd6047da677bc0782c64e10e1 | Rust | DianaNites/linapi | /src/util.rs | UTF-8 | 1,898 | 2.890625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Utility functions
use crate::system::UEventAction;
use std::{collections::HashMap, fs, io::prelude::*, path::Path};
/// Technically Linux requires sysfs to be at `/sys`, calling it a system
/// configuration error otherwise.
///
/// But our upcoming distro is planning to experiment with filesystem layout
/// chang... | true |
2e905f5c2e26b6e6b5f98bc939d7c9197383c61d | Rust | linianhui/div | /src/class/constant_class.rs | UTF-8 | 499 | 2.515625 | 3 | [
"MIT"
] | permissive | // https://docs.oracle.com/javase/specs/jvms/se12/html/jvms-4.html#jvms-4.4.1
/*
CONSTANT_Class_info {
u1 tag;
u2 name_index;
}
*/
use crate::class::ConstantTag;
use crate::class::U8Reader;
#[derive(Debug)]
pub struct ConstantClass {
pub tag: ConstantTag,
pub name_index: u16,
}
impl ConstantClass {
... | true |
6a48d424207c7643643bc0ed7469465d7415524c | Rust | janslee/rust-LD46 | /src/lines.rs | UTF-8 | 2,948 | 3 | 3 | [] | no_license | use crate::*;
fn produce_end_cap(
center: Vector3,
right: Vector3,
forward: Vector3,
resolution: u32,
vertices: &mut Vec<Vector3>,
indices: &mut Vec<[u32; 3]>,
) {
let start = vertices.len() as u32;
vertices.push(center - right);
vertices.push(center + right);
let increment = c... | true |
709dad930858ebb831475bdd71a7e51b09137a53 | Rust | GirkovArpa/sciter-tiscript-from-rust | /src/main.rs | UTF-8 | 686 | 2.625 | 3 | [
"Unlicense"
] | permissive | extern crate sciter;
use sciter::{HELEMENT, Element, Value};
use std::env;
struct EventHandler {}
impl sciter::EventHandler for EventHandler {
fn on_script_call(&mut self, root: HELEMENT, caller_function: &str, argv: &[Value]) -> Option<Value> {
let _func = argv.first().unwrap().as_string().unwrap();
let func = _f... | true |
8facf03237a74b35a996187811ad7fcddbc96fd8 | Rust | Montessquio/Rust-OS | /src/task/shell/util.rs | UTF-8 | 1,830 | 3.25 | 3 | [
"MIT"
] | permissive | // The echo command simply repeats its arguments back to the user.
// The echoparam command does so with debug output.
use alloc::vec::Vec;
use crate::{print, println};
pub fn help() {
println!(r#"Kernel Shell (ksh) version 0.0.1
echo <params...>: Shell test utility. Display a line of text.
echopara... | true |
961202d780773a77cdd9f58ced3ea2ddf971ce43 | Rust | iampritishpatil/rust_for_scicomp | /src/euler.rs | UTF-8 | 330 | 2.84375 | 3 | [
"MIT"
] | permissive | pub fn euler_int(y0:f32 , t0:f32, tmax:f32,nsteps:i32 , der:fn(f32,f32) -> f32 ) -> (){
let mut step_no=0;
let mut y=y0;
let mut t=t0;
let step_size=(tmax-t0)/nsteps as f32;
while step_no <nsteps {
t+=step_size;
y+=step_size*der(y,t);
println!("{} {}", t,y);
step_no+=... | true |
225f0d525e6000b5862959a19165bb3519d9b3b0 | Rust | acburdine/aoc-2015-rust | /day05/src/main.rs | UTF-8 | 2,295 | 3.390625 | 3 | [] | no_license | use std::collections::HashSet;
use std::fs;
const VOWELS: &str = "aeiou";
const NOT_ALLOWED: [&str; 4] = ["ab", "cd", "pq", "xy"];
fn is_nice(s: &str) -> bool {
let mut vowel_ct = 0;
let mut dbl_ltr = false;
for pt in NOT_ALLOWED.iter() {
if s.contains(pt) {
return false;
}
... | true |
d06c708b0ccb753a6ecd077ad6d702bd03739df6 | Rust | GTxx/leetcode | /algorithms/530. Minimum Absolute Difference in BST/solution/src/main.rs | UTF-8 | 2,599 | 3.5 | 4 | [] | no_license | use std::{cell::RefCell, cmp, rc::Rc};
// 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: i32) -> Self {
Tre... | true |
61267320afe5f2ea7b58a969bc84fff7e07af749 | Rust | carlosgj94/UnicoreChain | /p2p/src/server.rs | UTF-8 | 2,243 | 2.828125 | 3 | [] | no_license | extern crate actix_web;
use self::actix_web::http::Method;
use self::actix_web::{
error, server, App, Error, HttpMessage, HttpRequest, HttpResponse, Json, Result,
};
extern crate json;
extern crate serde_json;
use std::collections::HashMap;
#[derive(Serialize)]
struct Connection {
address: String,
alive: b... | true |
a1da8ac1c63299cf8d387d9e1b4ce78a0126f33d | Rust | archer884/iter-or | /src/lib.rs | UTF-8 | 1,722 | 3.609375 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | #![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", plugin(clippy))]
use std::iter::{self, Chain, Once};
/// Allows an iterator to produce a default value in the event it produces nothing else.
pub trait IterOr
where Self: Iterator + Sized
{
/// Causes an iterator to produce a defaul... | true |
672d4c7e646a9fd5072a53b9512375a91fafd2c1 | Rust | rust9x/rust | /src/test/run-make-fulldeps/coverage/generics.rs | UTF-8 | 1,409 | 3.671875 | 4 | [
"MIT",
"BSD-3-Clause",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"NCSA"
] | permissive | #![allow(unused_assignments)]
// expect-exit-status-1
struct Firework<T> where T: Copy + std::fmt::Display {
strength: T,
}
impl<T> Firework<T> where T: Copy + std::fmt::Display {
#[inline(always)]
fn set_strength(&mut self, new_strength: T) {
self.strength = new_strength;
}
}
impl<T> Drop fo... | true |
4e70e11c36f1ff81456f4cf8109337779904af40 | Rust | tscs37/boringos | /kernel/src/common/init/memory.rs | UTF-8 | 3,334 | 2.546875 | 3 | [] | no_license |
use crate::common::*;
use crate::common::ALLOCATOR;
use crate::vmem;
fn init_physical_memory_offset(boot_info: &'static bootloader::BootInfo) {
debug!("creating kernel vmem");
unsafe{
crate::vmem::pagetable::init(VirtAddr::new(boot_info.physical_memory_offset));
pager()
.init(VirtAddr::new(boot_info... | true |
8346dd499c0acfd23e3f793db1bdd81126a96658 | Rust | janigbg/sudokugen | /src/generator/mod.rs | UTF-8 | 1,319 | 3.265625 | 3 | [
"Unlicense"
] | permissive | use super::board::SudokuBoard;
use std::convert::From;
use std::fmt;
pub mod random_gen;
#[derive(Clone, Copy, Debug, PartialOrd, PartialEq)]
pub enum Difficulty {
Easy,
Medium,
Hard,
Evil,
}
impl From<u32> for Difficulty {
fn from(x: u32) -> Self {
match x {
0 => Difficulty::... | true |
c6c6d5dc4a5c53a49364c1c0d4be05f3f58ee9b1 | Rust | w3f-grants-archive/sup | /src/config.rs | UTF-8 | 4,964 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | //! Sup config
use crate::Result;
use etc::{Etc, FileSystem, Meta, Read, Write};
use serde::{Deserialize, Serialize};
use std::{path::PathBuf, process::Command};
/// Get value from equation
fn get(src: &str, key: &str) -> String {
if let Some(mut begin) = src.find(key) {
begin = src[begin..].find('=').unwr... | true |
fb6327bb4dbcb160bb8b617d3985fe6acc174357 | Rust | albmar/astro-rust | /src/atmos.rs | UTF-8 | 4,379 | 2.984375 | 3 | [
"MIT"
] | permissive | /*
Copyright (c) 2015, 2016 Saurav Sachidanand
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, di... | true |
9d16789f3f964d8a90eecafa9d1f252fed4dd287 | Rust | fewensa/rtdlib | /src/types/text_entity_type.rs | UTF-8 | 46,493 | 2.921875 | 3 | [
"MIT"
] | permissive |
use crate::types::*;
use crate::errors::*;
use uuid::Uuid;
use std::fmt::Debug;
use serde::de::{Deserialize, Deserializer};
/// TRAIT | Represents a part of the text which must be formatted differently
pub trait TDTextEntityType: Debug + RObject {}
/// Represents a part of the text which must be formatted diff... | true |
4d1df14e646ad6938e2b28f3683f7e4298e597b0 | Rust | mcmahonliam837/bevy | /crates/bevy_ecs/src/system/system.rs | UTF-8 | 1,211 | 2.765625 | 3 | [
"MIT"
] | permissive | use crate::resource::Resources;
use bevy_hecs::{ArchetypeComponent, TypeAccess, World};
use std::{any::TypeId, borrow::Cow};
/// Determines the strategy used to run the `run_thread_local` function in a [System]
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum ThreadLocalExecution {
Immediate,
NextFlush,
}... | true |
3757252396e1233d79725585315952a62de139b2 | Rust | Riuchando/projectEuler | /rust/src/problem003.rs | UTF-8 | 494 | 3.1875 | 3 | [] | no_license | use std::vec::Vec;
fn prime_factors(value: u64) -> Vec<u64> {
let mut factors = Vec::new();
let mut value = value;
let mut calc = 2;
while value > 1 {
while value % calc == 0 {
factors.push(calc);
value = value / calc;
}
calc = calc + 1;
}
factors... | true |
65d39e4c431ff1dd0632685dacede65e12e915f0 | Rust | mmgeorge/rust-odata | /src/service/handler.rs | UTF-8 | 8,860 | 2.96875 | 3 | [] | no_license |
use std::io::{Read, Write};
use std::sync::Arc;
use std::collections::HashMap;
use std::clone::Clone;
use std::mem;
use hyper::server::{Handler, Request, Response};
use hyper::status::StatusCode;
use hyper::method::Method;
use hyper::uri::RequestUri;
use serde_json::{Value, to_vec, to_string, from_slice, from_str};
... | true |
67f95e41a24391f917462439700b6960e8a55110 | Rust | wapm-packages/coreutils | /src/env/env.rs | UTF-8 | 7,850 | 2.65625 | 3 | [
"MIT"
] | permissive | #![crate_name = "uu_env"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/* last synced with: env (GNU coreutils) 8.13 */
#[macr... | true |
06a13041c40f7804c0d17e17d65b5dc9a98a9445 | Rust | Geal/incrust | /src/parser/macros.rs | UTF-8 | 1,354 | 3.015625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[macro_export]
macro_rules! stmt {
( $i:expr, $cmd: expr ) => ({
use nom::multispace;
use ::parser::expressions::full_expression;
chaining_parser!($i, 0usize,
tag!("{%") ~
l: opt!(tag!("-")) ~
many0!(multispace) ~
... | true |
f4a128ec3a38a9e96584d4cc0aad876955bebbda | Rust | jinjagit/shortest_path | /src/plot_trails.rs | UTF-8 | 1,849 | 2.671875 | 3 | [] | no_license | use plotters::prelude::*;
#[allow(dead_code)]
pub fn plot_trails(
coords: std::vec::Vec<(f32, f32)>,
title: &str,
file_path: &str,
matrix: Vec<Vec<f32>>,
best_route: Vec<usize>,
) -> Result<(), Box<dyn std::error::Error>> {
let file_path: &str = &(format!("{}", file_path));
let root = BitMa... | true |
3e92c8760cf381bb58e5a2bfe1e938e878f62a4b | Rust | uwe-app/bracket | /src/lexer.rs | UTF-8 | 19,275 | 3.3125 | 3 | [] | no_license | //! Iterator for grammar tokens.
use logos::{Lexer as Lex, Logos, Span};
/// Identity type for the lexer modes.
#[derive(Clone, Default)]
pub struct Extras;
/// Tokens for the document and nested blocks.
#[derive(Logos, Clone, Debug, Eq, PartialEq)]
#[logos(extras = Extras)]
#[logos(subpattern identifier = r#"[^\s"!#... | true |
4a112bc3996ff92f189f6517581d3743ac224be6 | Rust | USER19112/rr-mod-tool | /src/bpe.rs | UTF-8 | 13,625 | 2.6875 | 3 | [] | no_license | // BPE
// [magic_num: u32][reserved: u32][compressed_len: u32][decompressed_len: u32]
// block
// [encoding_info: ..][block_len: u16][block_data: ..]
extern crate threadpool;
use std::cmp::Ordering;
use std::collections::{HashMap, HashSet, VecDeque};
use std::convert::TryFrom;
use std::fs::{create_dir_all, File};
use... | true |
331dad3e0b3004bd36071e60c6f7def2a1893445 | Rust | fbrv/youki | /crates/libcontainer/src/channel.rs | UTF-8 | 6,296 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use nix::{
sys::socket::{self, UnixAddr},
unistd::{self},
};
use serde::{Deserialize, Serialize};
use std::{
io::{IoSlice, IoSliceMut},
marker::PhantomData,
os::unix::prelude::RawFd,
};
#[derive(Debug, thiserror::Error)]
pub enum ChannelError {
#[error("failed unix syscalls")]
Nix(#[from] n... | true |
e6ea59e7e642fd25e73aaed455ebc41fe740ec8a | Rust | LiuJiazheng/dingir-exchange | /src/message/mod.rs | UTF-8 | 8,741 | 2.609375 | 3 | [] | no_license | use crate::market::Order;
use crate::types::{OrderEventType, SimpleResult};
use core::cell::RefCell;
use anyhow::{anyhow, Result};
use crossbeam_channel::RecvTimeoutError;
use rdkafka::client::ClientContext;
use rdkafka::config::ClientConfig;
use rdkafka::error::{KafkaError, RDKafkaErrorCode};
use rdkafka::producer::{... | true |
47a3d0c7dd5cb9fcb43cc72df28b40d4889fa878 | Rust | ItsHoff/color_play | /src/process.rs | UTF-8 | 8,634 | 2.765625 | 3 | [] | no_license | use std::collections::HashMap;
use std::cell::RefCell;
use cgmath::conv::*;
use cgmath::{Matrix4, Vector2};
use glium::texture::{SrgbTexture2d, MipmapsOption, Texture2d, UncompressedFloatFormat};
use glium::{implement_vertex, uniform, DrawParameters, IndexBuffer, Surface, VertexBuffer};
use glium::backend::glutin::Di... | true |
2fdb13e18e720980e1d59b01a0dbc84b5212c0b4 | Rust | binier/tezedge-debugger | /tezedge-memprof/src/memory_map.rs | UTF-8 | 4,128 | 2.78125 | 3 | [
"MIT"
] | permissive | // Copyright (c) SimpleStaking, Viable Systems and Tezedge Contributors
// SPDX-License-Identifier: MIT
use std::{ops::Range, num::Wrapping, str::FromStr, io::{self, Read}, fs::File, path::PathBuf};
#[derive(Default, Clone, PartialEq, Eq)]
pub struct ProcessMap(Vec<MemoryMapEntry>);
impl ProcessMap {
pub fn new(... | true |
9e21d5156957f8694bae4000517ce3b3111366b3 | Rust | omerbenamram/mft | /src/err.rs | UTF-8 | 2,519 | 2.796875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::path::{Path, PathBuf};
use thiserror::Error;
pub type Result<T> = ::std::result::Result<T, Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error("An I/O error has occurred")]
IoError {
#[from]
source: std::io::Error,
},
#[error("Failed to open file {}", path.display())]
... | true |
8c733623c2bbbc742992fa8cff5e31f9eba85ca1 | Rust | zmilan/tinychain | /prototype/gateway/time.rs | UTF-8 | 703 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use std::ops;
use std::time;
#[derive(Clone)]
pub struct NetworkTime {
nanos: u128,
}
impl NetworkTime {
pub fn now() -> NetworkTime {
NetworkTime::from_nanos(
time::SystemTime::now()
.duration_since(time::UNIX_EPOCH)
.unwrap()
.as_nanos(),
... | true |
684f7d673ba02f8725af5f754e35db90cb4a4b79 | Rust | 4ge32/rddsv | /examples/m_mutex2.rs | UTF-8 | 4,133 | 2.75 | 3 | [] | no_license | use rddsv::lts::*;
use rddsv::process::*;
use std::fmt;
#[derive(Default, std::fmt::Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct SharedVars {
pub m0: i32, // mutex0
pub m1: i32, // mutex1
}
impl fmt::Display for SharedVars {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!... | true |
bb08a5ae032300604dfe4eff506e8d0ebe749e33 | Rust | jazz-lang/WaffleLink | /src/gc.rs | UTF-8 | 3,856 | 3.40625 | 3 | [
"Apache-2.0"
] | permissive | use std::cmp::{Ord, Ordering, PartialOrd};
use std::fmt;
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct Address(usize);
impl Address {
pub fn deref(self) -> Self {
unsafe { *(self.offset(0).to_mut_ptr::<Self>()) }
}
#[inline(always)]
pub fn from(val: usize) -> Address {
Address(... | true |
79fbf6f9308192949f80692ca3baf0c76badc2e4 | Rust | jeremybobbin/jer-ft | /src/bin/recv.rs | UTF-8 | 1,356 | 2.734375 | 3 | [] | no_license | use std::{
fs::{
self,
File
},
net::{
TcpListener,
TcpStream
},
io::{
self,
Read,
Write,
BufReader
},
sync::{
mpsc,
Arc,
Mutex,
},
thread::{
self,
JoinHandle
}
};
fn main() {
... | true |
6ce6b20a3d21737c19984731613509e5f048a374 | Rust | ftsujikawa/rust-sample | /ch08/code8-3/src/main.rs | UTF-8 | 265 | 3.609375 | 4 | [] | no_license | struct Person {
id: i32,
name: String,
age: i32,
addr: String,
}
fn main() {
let pa = Person {
id: 100,
name: String::from("masuda"),
age: 50,
addr: String::from("Tokyo"),
};
println!("Hello, world!");
}
| true |
2f2821f782381a05139251d0d4e8d1334c2c2200 | Rust | jesperancinha/rust-test-drive | /src/node_manager.rs | UTF-8 | 1,110 | 3.390625 | 3 | [
"Apache-2.0"
] | permissive | use std;
fn max(x: i32, y: i32) -> i32 {
if x < y { y } else { x }
}
enum Tree {
Empty,
Leaf(i32),
Node(Box<Tree>, Box<Tree>)
}
impl std::fmt::Display for Tree {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
&Tree::Empty => write!(f, "Empty: ({})", 0),
&Tree::Leaf... | true |
059ea9dd781f662ffa73e05bb89c47472eaf3f40 | Rust | mhuesch/poly-rs | /src/syntax.rs | UTF-8 | 1,377 | 2.984375 | 3 | [
"MIT"
] | permissive | #[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Name(pub String);
#[derive(Clone, Debug, PartialEq)]
pub enum Expr {
Var(Name),
App(Box<Expr>, Box<Expr>),
Lam(Name, Box<Expr>),
Let(Name, Box<Expr>, Box<Expr>),
Lit(Lit),
If(Box<Expr>, Box<Expr>, Box<Expr>),
Fix(Box<Expr>),
Prim(P... | true |
c887f9320d655a817e05083490cc9276a0186597 | Rust | m0dulo/Wispha | /src/commandline/interact/get.rs | UTF-8 | 2,810 | 2.90625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use libwispha::core::{Tree, NodePath};
use structopt::StructOpt;
use std::error;
use std::fmt;
#[derive(StructOpt)]
#[structopt(rename_all = "kebab-case")]
pub struct GetOptions {
#[structopt(long, short)]
key: String,
/// Node path for the node
#[structopt(long, short)]
path: String,
}
impl Get... | true |
2cbff947a980f5017526968fab498111fe89d7c5 | Rust | jblindsay/whitebox-tools | /whitebox-tools-app/src/tools/lidar_analysis/lidar_outliers.rs | UTF-8 | 22,246 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /*
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 06/02/2018
Last Modified: 18/10/2019
License: MIT
*/
use whitebox_lidar::*;
use whitebox_common::structures::{DistanceMetric, FixedRadiusSearch2D, Point3D};
use crate::tools::*;
use num_cpus;
use std::cmp::Orderin... | true |
ffba99bf4319f69ddb5a427ead613e5f52e78d56 | Rust | bvinc/eddy-gtk3 | /eddy-workspace/src/msg.rs | UTF-8 | 448 | 2.625 | 3 | [] | no_license | use crate::BufferId;
#[derive(Copy, Clone, Debug)]
pub enum Msg {
LsInitialized,
PathChanged(BufferId),
}
pub struct MsgSender {
pub callback: Option<Box<dyn 'static + Sync + Send + FnMut(Msg)>>,
}
impl MsgSender {
pub fn new() -> MsgSender {
MsgSender { callback: None }
}
pub fn send... | true |
d63b310fd2618873bc21a09cb947439d39d32609 | Rust | jmhodges/hap-rs | /src/transport/http/handler/characteristics.rs | UTF-8 | 5,699 | 2.625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::collections::HashMap;
use hyper::{Body, Response, StatusCode, Uri};
use url::form_urlencoded;
use crate::{
config::ConfigPtr,
db::{AccessoryList, DatabasePtr},
event::EventEmitterPtr,
protocol::IdPtr,
transport::http::{
handler::JsonHandler,
json_response,
server::... | true |
28704e6288f674b345c2e5229f0da672927c644b | Rust | mikevinmike/rust-syslog | /examples/log.rs | UTF-8 | 571 | 2.53125 | 3 | [
"MIT"
] | permissive | //! using syslog with the log crate
#[macro_use]
extern crate log;
extern crate syslog;
use log::LevelFilter;
use syslog::{BasicLogger, Facility, Formatter3164};
fn main() {
let formatter = Formatter3164 {
facility: Facility::LOG_USER,
hostname: None,
process: "myprogram".into(),
pid: 0,
};
le... | true |
226c069d8bca833dd42827670760d5f19ff005dd | Rust | amuttsch/serde_bencoded | /src/ser/only_string_ser.rs | UTF-8 | 7,862 | 2.953125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::io::Write;
use serde::{ser, Serialize};
use crate::error::SerError as Error;
pub(crate) struct OnlyStringSerializer<'s, W: Write> {
pub(crate) ser: &'s mut super::Serializer<W>,
}
impl<'s, W: Write> ser::Serializer for &'s mut OnlyStringSerializer<'s, W> {
type Ok = ();
type Error = Error;
... | true |
dda823b88935b76e7d779053bdd5588b1d485082 | Rust | jmcolella/advent-of-code-2020 | /src/day_6/solution.rs | UTF-8 | 1,360 | 3.25 | 3 | [] | no_license | use std::fs;
use std::collections::HashMap;
use itertools::Itertools;
fn parse_file() -> Vec<Vec<String>> {
let file = fs::read_to_string("src/day_6/input.txt").unwrap();
let lines = file.as_str().lines();
let mut values: Vec<Vec<String>> = Vec::new();
let mut temp: Vec<String> = Vec::new();
for l in lines... | true |
780c76e770c632ab8f7487242dae185e1a985306 | Rust | indirect/matasano_challenges | /tests/set01-challenge02.rs | UTF-8 | 496 | 2.765625 | 3 | [] | no_license | extern crate "rustc-serialize" as serialize;
extern crate xor;
use serialize::hex::{FromHex,ToHex};
use xor::Xor;
#[test]
fn set01_challenge02() {
let source = "1c0111001f010100061a024b53535009181c";
let other = "686974207468652062756c6c277320657965";
let source_bytes = source.from_hex().unwrap();
let... | true |
019bbeec1b89208497d8e673d1b796f8471fb74a | Rust | dpogretskiy/pcars2-power-graphs | /src/cars/mod.rs | UTF-8 | 3,982 | 3 | 3 | [
"MIT"
] | permissive | pub mod data;
use ggez::graphics::*;
use ggez::*;
use std::cmp::Ordering;
use std::collections::HashSet;
use strsim;
use app;
pub struct AllCarsData {
data: Vec<CarInfoCached>,
current_car_ix: Option<usize>,
font: Font,
}
impl AllCarsData {
pub fn new(font: Font) -> AllCarsData {
let data = ... | true |
a26d1af9c145e7e08de923705fdfc369bb8f754d | Rust | apasel422/tree | /src/quickcheck.rs | UTF-8 | 951 | 2.53125 | 3 | [] | no_license | extern crate quickcheck;
use compare::Compare;
use self::quickcheck::{Arbitrary, Gen};
use super::{Map, Set};
impl<K, V, C> Arbitrary for Map<K, V, C>
where K: Arbitrary, V: Arbitrary, C: 'static + Clone + Compare<K> + Default + Send {
fn arbitrary<G: Gen>(gen: &mut G) -> Self {
Vec::<(K, V)>::arbitr... | true |
9ff7f890d4a7df2d15d62d3a5595d99b1e37954e | Rust | bbqsrc/sentry-rust-1 | /sentry-debug-images/src/integration.rs | UTF-8 | 1,232 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | use std::borrow::Cow;
use sentry_core::protocol::{DebugMeta, Event};
use sentry_core::{ClientOptions, Integration};
/// The Sentry Debug Images Integration.
pub struct DebugImagesIntegration {
/// A custom filter for which Events should get debug images.
pub filter: Box<dyn Fn(&Event<'static>) -> bool + Send ... | true |
25d16801517d95a5b89b13a877fc647541310288 | Rust | nyeogmi/moogle | /src/raw_junctions/many_to_many/extra.rs | UTF-8 | 8,343 | 2.96875 | 3 | [] | no_license | // stock trait implementations
// trait list taken from https://doc.rust-lang.org/std/collections/struct.BTreeMap.html
// not implementing Index, it requires a Ref-based interface
// not implementing IntoIterator here as it has complicated lifetime issues
use std::{iter::FromIterator};
use std::hash::Hash;
use crate:... | true |
72920c9310b714e0872689af87d68db306c5ca68 | Rust | ErnestoGithubCode/Rust_language_test_bed | /src/main.rs | UTF-8 | 146 | 2.65625 | 3 | [] | no_license | extern crate exit_code;
fn main() {
use std::process::exit;
use exit_code::SUCCESS;
println!("Hello, World!");
exit(SUCCESS);
}
| true |
87e5414420219b6be482398943c08c5bcdaa7837 | Rust | meh/rust-terminfo | /src/error.rs | UTF-8 | 1,831 | 2.859375 | 3 | [
"WTFPL"
] | permissive | // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
//
// Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co
//
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long... | true |
8a7be05972cba416049a4d3472d61da2365470b5 | Rust | lucarin91/halftone-glyph | /src/bin/hatogl.rs | UTF-8 | 3,993 | 2.78125 | 3 | [
"MIT"
] | permissive | extern crate halftoneglyph;
extern crate font_kit;
#[macro_use]
extern crate clap;
extern crate image;
extern crate rand;
use clap::{App, Arg};
use font_kit::family_name::FamilyName;
use font_kit::font::Font;
use font_kit::properties::Properties;
use font_kit::source::SystemSource;
use halftoneglyph::{image_to_unicod... | true |
13fb01da731ccaf35ec1cdd28faf2d9ca8c8f8fa | Rust | stadelmanma/garmin-run-tracker | /garmin_run_tracker/src/db/mod.rs | UTF-8 | 6,841 | 2.765625 | 3 | [
"MIT"
] | permissive | //! Database utility functions and the schema definition
use crate::{data_dir, Error, FileInfo};
use chrono::Utc;
use fitparser::Value;
use log::{debug, error};
use rusqlite::types::ToSqlOutput;
use rusqlite::{Connection, Result, ToSql};
use std::convert::TryFrom;
use std::fmt;
use std::ops::Deref;
use std::path::PathB... | true |
bda7c4941feea333ec0c5a4e68e77d6f39a4b769 | Rust | ivfranco/notes | /AI/searching/src/eight_queens.rs | UTF-8 | 2,290 | 2.984375 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | use crate::local_search::Local;
use crate::utils::diff;
use std::hash::{Hash, Hasher};
use rand::{
distributions::{Distribution, Standard},
prelude::*,
};
type Queen = usize;
const N_QUEENS: usize = 8;
#[derive(Clone)]
pub struct Queens {
columns: [Queen; N_QUEENS],
}
impl PartialEq for Queens {
fn ... | true |
b72ee1bcc37f5aeee75487c33098021c1787af4b | Rust | BlaximusIV/AdventOfCode2020 | /day_02/password_philosophy/src/main.rs | UTF-8 | 2,453 | 3.703125 | 4 | [] | no_license | use std::{error::Error, fs};
struct AuditItem {
target_char: char,
first_position: usize,
second_position: usize,
password: String,
}
impl AuditItem {
fn is_valid(&self) -> bool {
// This is optimistic, assuming password length aligns with policy indexes
let char_at_first_index = s... | true |
0f1d9abd5c1a889a7b4d307054f5f5a4df9bfb82 | Rust | adamransom/spyparsey | /src/matched_replay.rs | UTF-8 | 1,546 | 3.109375 | 3 | [] | no_license | use spyparty::Replay;
use std::cmp::Ordering;
/// A struct representing a combination of a replay and the path it was found at.
pub struct MatchedReplay {
/// The parsed replay.
pub inner: Replay,
/// The path the replay was found at.
pub path: String,
}
impl Ord for MatchedReplay {
fn cmp(&self, ... | true |
50c40c837737f579badff0735a918d4f9a113088 | Rust | monkeylyf/interviewjam | /arr/leetcode_degree_of_an_array.rs | UTF-8 | 1,898 | 3.71875 | 4 | [] | no_license | /**
* Given a non-empty array of non-negative integers nums, the degree of this
* array is defined as the maximum frequency of any one of its elements.
*
* Your task is to find the smallest possible length of a (contiguous) subarray
* of nums, that has the same degree as nums.
*
* Example 1:
* Input: [1, 2, 2, ... | true |
4a7d0ad0f463d1b11047afaf22872d0f7ce4ac73 | Rust | JojiiOfficial/rust-arch | /alpm-rs/src/macros.rs | UTF-8 | 2,106 | 3.28125 | 3 | [
"MIT"
] | permissive | /// string to c-string
/// required to be converted back to rust string after use
/// to avoid memory leaking
macro_rules! strc_noctx {
($e:expr) => {
std::ffi::CString::new($e).expect("CString::new failed").into_raw()
};
}
macro_rules! str_fromraw {
($e:expr) => {
std::ffi::CString::from_r... | true |
10547608c39c78ce46fa384b4fb06a3d8561daf7 | Rust | AlexanderEkdahl/pbr | /src/scene.rs | UTF-8 | 924 | 3.125 | 3 | [] | no_license | use surface::Surface;
use std::f64::INFINITY;
use ray3::Ray3;
use constants::UP;
use energy::Energy;
#[derive(Debug)]
pub struct Scene<'a> {
surfaces: &'a Vec<Box<Surface + 'a>>,
}
impl<'a> Scene<'a> {
pub fn new(surfaces: &'a Vec<Box<Surface + 'a>>) -> Scene<'a> {
Scene {
surfaces: surfac... | true |
c12f19c704d3a3cf1ec5757242545c35c3d1882f | Rust | moses-palmer/labyru | /maze/src/lib.rs | UTF-8 | 15,573 | 2.828125 | 3 | [] | no_license | #![cfg_attr(feature = "cargo-clippy", deny(clippy::all))]
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg(test)]
mod test_utils;
#[macro_use]
mod macros;
pub mod wall;
pub mod shape;
pub use self::shape::Shape;
pub mod initialize;
pub mod matrix;
pub mod physical;
pub mod render;
pub mod room... | true |
2ed36d809cdec9e505b57282656c6da4aa264ec0 | Rust | xianxianzhou/rust-tcp | /client/src/main.rs | UTF-8 | 1,418 | 3.375 | 3 | [] | no_license | use std::io::{self, prelude::*, BufReader, Write}; //导入io包 其中BufReader每次读取较多的内容,并且在内存中维护读取的结果,减少Read系统调用的次数,提高效率。
use std::net::TcpStream; //导入net包,tcp流
use std::str; //导入标准库str,对字符串进行处理
fn main() -> std::io::Result<()> {
let mut stream = TcpStream::connect("127.0.0.1:8080")?; //发起TCP连接
for _ in 0..10 { //假设交互... | true |
5ed240d5d426363dfdc35226f0943180472042e6 | Rust | mcginty/hevc-datamosh | /src/main.rs | UTF-8 | 2,331 | 2.984375 | 3 | [] | no_license | extern crate histogram;
extern crate rand;
use std::fs::File;
use std::fs::OpenOptions;
use std::io::{BufReader, BufWriter};
use std::io::prelude::*;
use histogram::Histogram;
use rand::Rng;
fn get_histogram() -> (Histogram, Vec<u64>) {
let f = File::open("in.hevc").expect("couldn't open file");
let mut reade... | true |
654ca0dec4421aae853034d54faaf386258954ed | Rust | MatsLanGoH/the-book.rs | /numbers_to_names/src/main.rs | UTF-8 | 320 | 3.28125 | 3 | [
"MIT"
] | permissive | // Solution for Ex21 Numbers to Names
// Input a number
// Output the corresponding month
use numbers_to_names::{
get_month_from_number,
get_number_input,
};
fn main() {
let number = get_number_input();
let month = get_month_from_number(&number);
println!("The name of the month is {}.", month);
}
| true |
7fe5683e55d79729f4c35acffe2789867454c90b | Rust | tailhook/unshare | /src/zombies.rs | UTF-8 | 5,186 | 3.0625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::marker::PhantomData;
use libc::pid_t;
use nix::sys::wait::{waitpid};
use nix::sys::wait::WaitPidFlag;
use nix::errno::Errno::{EINTR, ECHILD};
use nix::Error;
use crate::{ExitStatus, Signal};
/// A non-blocking iteration over zombie processes
///
/// Use `reap_zombies()` to create one, and read docs there
pu... | true |
13111492cf6ddc197ef50ee9d0f955f946fa2329 | Rust | Horki/wasm-tools | /crates/wasm-mutate/src/mutators/peephole/eggsy/lang.rs | UTF-8 | 50,082 | 3.359375 | 3 | [
"LLVM-exception",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Nodes for intermediate representation of Wasm operators
//!
use egg::Id;
use std::convert::TryInto;
use std::fmt::{self, Display};
use std::str::FromStr;
use wasm_encoder::ValType;
/// This is a macro used to define the `Lang` enum.
///
/// The goal of this macro is to synthesize an implementation of the
/// `egg:... | true |
3fe39260ef126bb769321485f9f2523c85175e03 | Rust | xpeerchain/xpeerchain | /language/vm/src/proptest_types/signature.rs | UTF-8 | 4,281 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) The XPeer Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::file_format::{FunctionSignature, SignatureToken, StructHandleIndex, TableIndex};
use proptest::{
collection::{vec, SizeRange},
prelude::*,
sample::{select, Index as PropIndex},
};
#[derive(Clone, Debug)]
pub str... | true |
cab69959240bca0c0c53f5d1779256d8718f7860 | Rust | adradek/sicp | /1.18/solution.rs | UTF-8 | 526 | 3.28125 | 3 | [] | no_license | fn main() {
println!("12 * 8 = {}", calc(12, 8));
println!("9 * 6 = {}", calc(9, 6));
println!("3 * 11 = {}", calc(3, 11));
println!("16 * 16 = {}", calc(16, 16));
}
fn calc(a: u32, b: u32) -> u32 {
return calc_iter(a, b, 0);
}
fn calc_iter(a: u32, b: u32, buf: u32) -> u32 {
if a == 0 || b == ... | true |
69f5490c1c39bbb36fc268bd3158712abdd313cf | Rust | Weasy666/egui | /crates/egui/src/animation_manager.rs | UTF-8 | 3,388 | 3.046875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{emath::remap_clamp, Id, IdMap, InputState};
#[derive(Clone, Default)]
pub(crate) struct AnimationManager {
bools: IdMap<BoolAnim>,
values: IdMap<ValueAnim>,
}
#[derive(Clone, Debug)]
struct BoolAnim {
value: bool,
/// when did `value` last toggle?
toggle_time: f64,
}
#[derive(Clone, D... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.