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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
449a94d79f03403ea2e87c197d3c831fd852d6ba | Rust | YoloDev/evitable | /syn-meta-ext/src/ast.rs | UTF-8 | 3,549 | 3.046875 | 3 | [
"MIT"
] | permissive | use syn::Ident;
enum Unreachable {}
impl std::fmt::Debug for Unreachable {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
unreachable!()
}
}
pub enum Fields<T> {
Named(Vec<(Ident, T)>),
Unnamed(Vec<(usize, T)>),
Unit,
}
impl<T> Fields<T> {
pub fn iter<'a>(&'a self) -> FieldsIter<'a... | true |
f720b7e0018407d337cebe81fd7d17712731e41b | Rust | wilhg/kinoko | /src/process.rs | UTF-8 | 1,213 | 3.3125 | 3 | [] | no_license | use regex::Regex;
use std::collections::HashMap;
pub struct Parser {
re: Regex,
}
impl Parser {
pub fn new(re: &str) -> Self {
Self {
re: Regex::new(re).unwrap()
}
}
pub fn parse(&self, input: &str) -> Vec<HashMap<String, String>> {
let mut result: Vec<HashMap<Stri... | true |
5884b3d63bd018a670afd08cf6f0cd7345af83c7 | Rust | RHRivasG/SBD1-Fragrances-Dashboard-Backend | /backend/RUST/evaluation-api/src/lib/auth/mod.rs | UTF-8 | 3,093 | 2.625 | 3 | [] | no_license | pub(crate) mod session;
use rocket_contrib::json::Json;
use rocket::{response::status, http::{Cookie, Cookies}};
use super::{providers::model::Provider, db::Connection, producers::model::Producer};
use diesel::select;
use diesel::{query_dsl::{LoadQuery, methods::LimitDsl}, prelude::*};
fn unload_expression<T, K>(exp:... | true |
0182b38015495accfa5fc5ddd73d5e40f85ef762 | Rust | barudisshu/dive-into-rust | /dive_into_rust/src/chap01/mod.rs | UTF-8 | 974 | 3.75 | 4 | [] | no_license | ///
/// 带`!`的都是标准库定义的宏,类似还有,
/// `format!` `write!` `writeln!` 参考标准库`std::fmt` 模块说明
///
#[test]
fn _01_05_format() {
println!("{}", 1); // 默认用法,打印Display
println!("{:o}", 9); // 八进制
println!("{:x}", 255); // 十六进制 小写
println... | true |
d9d91fade3c0c5f28b312269f8d23c6f4b462922 | Rust | jblee123/advent_of_code_2016 | /day24/b/main.rs | UTF-8 | 5,979 | 3.09375 | 3 | [] | no_license | use std::collections::HashSet;
use std::collections::LinkedList;
use std::fs;
// use std::result::Result;
// use std::str;
// use std::str::FromStr;
type Map = Vec<Vec<u8>>;
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
struct Coord {
x: u8,
y: u8,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
st... | true |
67f624af98bf0041ea7486868dc85475d3a7c29e | Rust | kuwana-kb/ddd-in-rust | /chapter08_sample_application/src/infrastructure/datastore/rdb_context.rs | UTF-8 | 1,709 | 2.9375 | 3 | [] | no_license | use std::convert::TryInto;
use std::fmt;
use anyhow::Result;
use crate::{
domain::{Name, User, UserId, UserRepository},
infrastructure::{PgPool, UserDto},
};
#[derive(Clone)]
pub struct RDBContext {
pool: PgPool,
}
impl Default for RDBContext {
fn default() -> Self {
let pool = PgPool::new()... | true |
e99f55a249447d470fe28e6e94d96cef219dc0a6 | Rust | Artentus/rEmu | /src/types.rs | UTF-8 | 44,522 | 3.375 | 3 | [
"MIT"
] | permissive | use num_traits::{
FromPrimitive, Num, NumAssign, One, ToPrimitive, Unsigned, WrappingAdd, WrappingMul,
WrappingShl, WrappingShr, WrappingSub, Zero,
};
use std::num::Wrapping;
use std::ops::{
Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
Mul, MulAssign, N... | true |
6fc4717ac8efa86ca60a9d8fabc0884a412b682d | Rust | nix-rust/nix | /test/test_poll.rs | UTF-8 | 2,456 | 2.78125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use nix::{
errno::Errno,
poll::{poll, PollFd, PollFlags},
unistd::{close, pipe, write},
};
use std::os::unix::io::{BorrowedFd, FromRawFd, OwnedFd};
macro_rules! loop_while_eintr {
($poll_expr: expr) => {
loop {
match $poll_expr {
Ok(nfds) => break nfds,
... | true |
d5f4649efdcf69efef89a433b6c8f4a3e724198e | Rust | b-goodman/dias | /src/template/mod.rs | UTF-8 | 1,451 | 2.9375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::fs;
use std::path::{Path, PathBuf};
use walkdir::WalkDir;
use console::style;
extern crate handlebars;
use handlebars::Handlebars;
pub fn merge(template_filepath: &Path, project_variables: &HashMap<&String, String>) -> String {
let reg = Handlebars::new();
let template... | true |
3730bb7f63724324ca6bc683fbedda20c4d3116b | Rust | planet-s/liner | /src/history.rs | UTF-8 | 15,107 | 3.15625 | 3 | [
"MIT"
] | permissive | use super::*;
use std::{
collections::{vec_deque, VecDeque},
fs::File,
io::{self, Write},
io::{BufRead, BufReader, BufWriter},
iter::IntoIterator,
ops::Index,
ops::IndexMut,
path::Path,
//time::Duration,
};
const DEFAULT_MAX_SIZE: usize = 1000;
/// Structure encapsulating command ... | true |
bd092e223fb000b6e4377437b58104def60627e2 | Rust | imlyzh/sexpr_ir | /src/gast/constant.rs | UTF-8 | 1,563 | 2.765625 | 3 | [
"MIT"
] | permissive | use std::fmt::Display;
use serde::{Serialize, Deserialize};
use super::{Handle, symbol::Symbol};
#[derive(Debug, Clone, PartialEq)]
#[derive(Serialize, Deserialize)]
pub enum Constant {
Nil,
Bool(bool),
Char(char),
Int(i64),
Uint(u64),
Float(f64),
Str(Handle<String>),
Sym(Handle<Symb... | true |
b3eb19afa6c4b5cd5f6dce5a8626d9b56c97b826 | Rust | iCodeIN/colorify | /src/lib.rs | UTF-8 | 7,898 | 3.40625 | 3 | [
"MIT"
] | permissive | //! Format text printed to the terminal using ANSI colors.
//!
//!
//!
//! ## Usage
//!
//! Add the following to your `Cargo.toml`:
//!
//! ```text
//! [dependencies]
//! colorify = "0.2"
//! ```
//!
//! ## Example
//!
//! ```
//! #[macro_use] extern crate colorify;
//! use std::io::{self, Write};
//!
//! fn main() {
/... | true |
49b5e9fb0ca1cbb99105c934a34e1253da1bd867 | Rust | blackbeam/rust_mysql_common | /src/crypto/rsa.rs | UTF-8 | 16,791 | 2.84375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright (c) 2021 Anatoly Ikorsky
//
// 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 notice may not be copied,
// m... | true |
886562b0b8e6281b79d87499eb68e7f5433dce55 | Rust | troyhart/jx3-rusthttpdemo | /src/main.rs | UTF-8 | 1,073 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use actix_files::NamedFile;
use actix_web::{web, App, HttpRequest, HttpServer, Responder, Result};
use std::path::PathBuf;
async fn greet(req: HttpRequest) -> impl Responder {
let name = req.match_info().get("name").unwrap_or("World");
format!("Hello {}!", &name)
}
async fn index(req: HttpRequest) -> Result<N... | true |
34be1d9b21b234cdb440674276f96ee57f752791 | Rust | ncoif/advent-2017 | /src/day10.rs | UTF-8 | 3,905 | 3.421875 | 3 | [] | no_license | use nom::types::CompleteStr;
use nom::{map_res, named, separated_nonempty_list, tag};
pub fn title() -> &'static str {
"Day 10: Knot Hash"
}
named!(
usize_parser<CompleteStr, usize>,
map_res!(nom::digit, |CompleteStr(s)| usize::from_str_radix(s, 10))
);
named!(
list_parser<CompleteStr, Vec<usize>>,
... | true |
0cd350e74af0be9af43ded03188219256068c0ef | Rust | wycats/argon | /crates/argon/src/lexer/tokenize.rs | UTF-8 | 10,964 | 2.625 | 3 | [] | no_license | use crate::prelude::*;
use super::Tok;
use crate::ir::pos::SpannedItem;
use crate::lexer::Token;
use lazy_static::*;
use log::*;
use unicode_xid::UnicodeXID;
lazy_static! {
static ref MATCHERS: Matchers = {
Matchers::keywords(&[
("export", Tok::Export),
("def", Tok::Def),
... | true |
7bde6fbdb464a01e439d2d574079e124e47a836b | Rust | spieglt/cryptopals | /src/set3/ex20.rs | UTF-8 | 1,682 | 3.0625 | 3 | [] | no_license | /*
Break fixed-nonce CTR statistically
In this file find a similar set of Base64'd plaintext. Do with them exactly what you did with the first, but solve the problem differently.
Instead of making spot guesses at to known plaintext, treat the collection of ciphertexts the same way you would repeating-key XOR.
Obvio... | true |
457cece5f9a676159b940eaea1a195a36ded02d4 | Rust | yxiuz/gvk | /src/vk_provider/user.rs | UTF-8 | 2,545 | 2.8125 | 3 | [] | no_license | use crate::models;
use crate::storage::Storage;
use rvk::{methods::users, objects::user::User as VKUser, APIClient, Params};
use std::boxed::Box;
use std::fmt;
pub struct User(pub Box<VKUser>);
impl User {
pub async fn query_async(api: &APIClient, user_id: &str) -> Option<Self> {
let mut params = Params::... | true |
5aaf08aefa4e591b4ed721f13ed81da404483602 | Rust | natebolam/coda | /src/lib/marlin_plonk_bindings/stubs/src/pasta_fp_vector.rs | UTF-8 | 778 | 2.515625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::caml_pointer::{self, CamlPointer};
use algebra::pasta::fp::Fp;
pub type CamlPastaFpVector = CamlPointer<Vec<Fp>>;
#[ocaml::func]
pub fn caml_pasta_fp_vector_create() -> CamlPastaFpVector {
caml_pointer::create(Vec::new())
}
#[ocaml::func]
pub fn caml_pasta_fp_vector_length(v: CamlPastaFpVector) -> oca... | true |
3b75c81799c6743e1a2793fe4a80df9eddc0bf10 | Rust | gorserg/udt-r | /src/server.rs | UTF-8 | 3,940 | 2.90625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::cli::{Options, ServerType};
use std::io::{Read, Write};
use std::net::{TcpListener, TcpStream};
use std::thread;
extern crate actix_web;
use actix_web::{server, http, HttpRequest, HttpResponse, fs, App};
fn handle_read(mut stream: &TcpStream) {
let mut buf = [0u8; 4096];
stream.read(&mut buf).unwr... | true |
3e5280f4409d6ac988e2f8a1ae9cec2404956bc9 | Rust | kildevaeld/vfs-rs | /_vfs/src/traits.rs | UTF-8 | 2,626 | 3.03125 | 3 | [] | no_license | use async_trait::async_trait;
use futures_lite::{
io::{AsyncRead, AsyncSeek, AsyncWrite},
Stream,
};
use std::borrow::Cow;
use std::io::Result;
pub trait VFile: AsyncRead + AsyncSeek + AsyncWrite + Send {}
pub trait VFS: Send + Sync {
type Path: VPath;
fn path(&self, path: &str) -> Self::Path;
}
#[as... | true |
9e20f0b54e532a3f08fe9c175f2b22fce74c7ecd | Rust | mindstorm38/adventofcode2020 | /src/day7.rs | UTF-8 | 2,447 | 3.296875 | 3 | [] | no_license | use std::collections::{HashMap, HashSet};
const INPUT: &str = include_str!("res/day7");
type BagRules = HashMap<String, HashMap<String, u32>>;
fn parse_rules(inp: impl Iterator<Item=String>) -> BagRules {
let mut rules = HashMap::new();
for line in inp {
let (color, content_raw) = line.split_at(li... | true |
86d68efe2278842448207b2f19e492f613a4769f | Rust | tilde35/glu | /src/event_state.rs | UTF-8 | 6,356 | 2.875 | 3 | [
"MIT"
] | permissive | use crate::event::{Event, MouseButton};
use crate::screen_units::Screen2d;
use glium::glutin as gl;
use noisy_float::prelude::*;
/// Persistant state associated with the events. This keeps track of things like which control keys
/// are currently pressed, location of the mouse, and the state of the mouse buttons.
#[de... | true |
736f32a59242cc9f73ea92074887832a1a35c383 | Rust | Terkwood/BUGOUT | /gateway/src/model.rs | UTF-8 | 4,129 | 2.8125 | 3 | [
"MIT"
] | permissive | use serde_derive::{Deserialize, Serialize};
use uuid::Uuid;
pub type GameId = Uuid;
pub type ReqId = Uuid;
pub type EventId = Uuid;
pub type ClientId = Uuid;
pub type SessionId = Uuid;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Copy)]
pub struct Identity {
#[serde(rename = "clientId")]
pub clie... | true |
c0cafd41a0d5eefe3d4346ff9e0181bf38563782 | Rust | northern-byte/srv-detector | /src/main.rs | UTF-8 | 1,692 | 2.625 | 3 | [] | no_license | #![feature(async_closure)]
mod probes;
mod errors;
mod multi_spawn;
use serde_derive::{Deserialize, Serialize};
use warp::Filter;
use url::Url;
use warp::http::StatusCode;
use std::convert::Infallible;
#[derive(Deserialize, Serialize)]
struct Payload {
domains: Vec<String>
}
#[tokio::main]
async fn main() {
... | true |
c643b8ef701462e04b793455b64e0e9456f4fc16 | Rust | rarewin/my-studies | /rust/rust-by-example/variable_bindings/variable_bindings/src/main.rs | UTF-8 | 348 | 3.046875 | 3 | [
"BSD-2-Clause"
] | permissive | fn main() {
let an_integer = 1_u32;
let a_boolean = true;
let unit = ();
let copied_integer = an_integer;
println!("An integer: {:?}", copied_integer);
println!("A boolean: {:?}", a_boolean);
println!("Meet the unit value: {:?}", unit);
let _unused_variable = 3_u32;
let _noisy_... | true |
82689b7d136478fd256153d4a01f158814ece072 | Rust | sinvalmendes/learning-rust | /src/notes_service/notes/src/api.rs | UTF-8 | 1,792 | 2.703125 | 3 | [] | no_license | use crate::model::NewNote;
use actix_web::{web, FromRequest, HttpRequest, HttpResponse, Responder};
use serde::Deserialize;
use crate::db;
pub fn create_note(note: web::Json<NewNote>, pool: web::Data<db::PgPool>) -> impl Responder {
let new_note = NewNote {
title: note.title.clone(),
content: note... | true |
e670b48a0073539d2dbb56e68a9503a172a425be | Rust | tokio-rs/loom | /tests/thread_local.rs | UTF-8 | 2,944 | 3.234375 | 3 | [
"MIT"
] | permissive | #![deny(warnings, rust_2018_idioms)]
use loom::thread;
use std::cell::RefCell;
use std::sync::atomic::{AtomicUsize, Ordering};
#[test]
fn thread_local() {
loom::thread_local! {
static THREAD_LOCAL: RefCell<usize> = RefCell::new(1);
}
fn do_test(n: usize) {
THREAD_LOCAL.with(|local| {
... | true |
2121c0b8dfc97c740bbe488bbc16b1b99eee5db4 | Rust | ncoish/aoc2018 | /day_1/src/main.rs | UTF-8 | 1,484 | 3.703125 | 4 | [] | no_license | use std::collections::HashSet;
use std::io::{self, Read};
use std::time::Instant;
fn main() {
let values = read_input();
let sum = find_sum(&values);
let timer = Instant::now();
let repeated_freq = find_repeated_frequency(&values);
println!("time to get repeated frequencies: {:?}", timer.elapsed())... | true |
615e49d45757eca6fc98a2a8f609da29ca745fdf | Rust | mightykho/raytracer | /src/geometry.rs | UTF-8 | 4,083 | 3.46875 | 3 | [] | no_license | use material::Material;
use vector::{Vector2, Vector3, Point};
use ray::Ray;
#[derive(Deserialize, Debug)]
pub enum Object {
Sphere(Sphere),
Plane(Plane)
}
#[derive(Deserialize, Debug)]
pub struct Sphere {
pub center: Point,
pub radius: f64,
#[serde(default)]
pub material: Material,
}
#[deri... | true |
7eda07e18a2cf21cc9143a2ba5c0673460469fba | Rust | ntn888/learnrust | /fibonacci/src/main.rs | UTF-8 | 417 | 3.6875 | 4 | [] | no_license | use std::io::BufRead;
fn main() {
println!("Hello, world!");
//let x = 9;
println!("Please input n:");
let mut n = String::new();
io::stdin().read_line(&mut n).expect("Failed to read line");
let n: i32 = n.trim().parse().expect("Please type a number!");
println!("{}", fib(n));
}
fn fib... | true |
cb533289e9b1fe8ccc8e95fcc6b4893e7dbb98c0 | Rust | chenenjie/kas | /src/widget/list.rs | UTF-8 | 13,847 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | // 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 in the LICENSE-APACHE file or at:
// https://www.apache.org/licenses/LICENSE-2.0
//! A row or column with run-time adjustable contents
use ... | true |
bc9812bcbf402c559770fb3edde963858a21e474 | Rust | Boscop/mincode | /src/lib.rs | UTF-8 | 3,390 | 3.546875 | 4 | [
"MIT"
] | permissive | //! `bincode` is a crate for encoding and decoding using a tiny binary
//! serialization strategy.
//!
//! There are simple functions for encoding to `Vec<u8>` and decoding from
//! `&[u8]`, but the meat of the library is the `encode_into` and `decode_from`
//! functions which respectively allow encoding into a `std::i... | true |
a30ab5b9444f186afca6a3cffd5d1289734a0b31 | Rust | giovanni-shibaki/path_planning | /kd_tree/src/visitor.rs | UTF-8 | 9,674 | 3.03125 | 3 | [] | no_license | use std::borrow::Borrow;
use std::marker::PhantomData;
use nalgebra as na;
use crate::HasCoords;
macro_rules! impl_default_with_new {
(impl$(<$($generics:tt),*>)? Default for $($type:tt)*) => {
impl$(<$($generics),*>)? Default for $($type)* {
fn default() -> Self {
Self::new()... | true |
fa00522258f37ca7c0f5793aedcc381214d63613 | Rust | tommady/leetcode | /rust/src/p1790_check_if_one_string_swap_can_make_strings_equal.rs | UTF-8 | 2,961 | 3.78125 | 4 | [] | no_license | // You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices.
//
// Return true if it is possible to make both strings equal by performing at most one string swap on exactly one of the ... | true |
3e730c42e31507fa839c27661532475635e7c09b | Rust | yew1eb/rustlab | /basic-exercises/src/std_binaryheap_base.rs | UTF-8 | 714 | 3.671875 | 4 | [
"MIT"
] | permissive | use std::collections::BinaryHeap;
fn show_remainder(input: &BinaryHeap<i32>) -> Vec<i32> {
let mut remainder_vec = vec![];
for number in input {
remainder_vec.push(*number);
}
remainder_vec
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn t_binaryheap() {
let many_numbers... | true |
39e7e9a580b6d79ab79e634db3a7185a3f27b86a | Rust | angelleon/k_means | /src/main.rs | UTF-8 | 1,211 | 2.796875 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufWriter, Write};
extern crate algorithms;
use algorithms::{k_means, KPoint, NPoint};
fn write_results(k_points: &Vec<KPoint>, n_points: &Vec<NPoint>) {
let f = File::create("points.json").expect("Can not open file");
let mut writer = BufWriter::new(f);
writer.write("{\"k... | true |
6bff525d67f1e1fac03937876ac50361422ca53e | Rust | Roger/exercism | /rust/matching-brackets/src/lib.rs | UTF-8 | 857 | 3.265625 | 3 | [] | no_license | const OPENS: [&char; 3] = [&'{', &'(', &'['];
const CLOSES: [&char; 3] = [&'}', &')', &']'];
/// find the balanced brackets
pub fn brackets_are_balanced(string: &str) -> bool {
// keep track of open brackets
let mut opens: Vec<char> = vec![];
for chr in string.chars() {
// Find close pair or None
... | true |
751058fa8d7f5869a0c1ca40e49435b2c813dc39 | Rust | rkat0/AtCoder | /Mujin2018/C.rs | UTF-8 | 3,247 | 3.03125 | 3 | [] | no_license | use io::*;
fn main() {
let input = read_string();
let mut sc = Scanner::new(&input);
let n: usize = sc.next();
let m: usize = sc.next();
let s = sc.next_mat_char(n);
let mut p: Vec<Vec<[usize;4]>> = vec![vec![[0,0,0,0];m];n];
for i in 0..n {
for j in 1..m {
if s[i][m-j-1... | true |
aaa9b53d8c883252125abecee3b992ff81f4b1e7 | Rust | pedrocr/wayland-rs | /wayland-client/src/event_queue.rs | UTF-8 | 22,356 | 2.640625 | 3 | [
"MIT"
] | permissive | use {Handler, Proxy};
use std::any::Any;
use std::io::{Error as IoError, Result as IoResult};
use std::io::Write;
use std::ops::{Deref, DerefMut};
use std::os::raw::{c_int, c_void};
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicPtr};
use wayland_sys::RUST_MANAGED;
use wayland_sys::client::*;
use waylan... | true |
9e4e6d1d13cdcc181a98cc6f1e43141c0fc3d24f | Rust | Adam-Gleave/aperture | /aperture/src/world/cube.rs | UTF-8 | 2,872 | 2.515625 | 3 | [] | no_license | use aperture_common::VPos;
use aperture_mesh::{ImageFormat, Texture};
use image::hdr::HdrDecoder;
use std::fs::File;
use std::io::BufReader;
pub struct Cube {
pub texture: Texture<f32>,
}
impl Cube {
pub const NUM_VERTICES: usize = 36;
pub const VERTICES: [VPos; Self::NUM_VERTICES] = [
VPos { p... | true |
2239ca5abd34493a65f3d95f1809d4f2ba830aea | Rust | luccasmmg/noodles | /noodles-bcf/examples/bcf_write.rs | UTF-8 | 1,047 | 2.671875 | 3 | [
"MIT"
] | permissive | //! Creates a new BCF file.
//!
//! This writes a BCF file format, VCF header, and a single VCF to stdout.
//!
//! Verify the output by piping to `bcftools view --no-version`.
use std::{convert::TryFrom, io};
use noodles_bcf as bcf;
use noodles_vcf::{self as vcf, header::Contig, record::Position};
fn main() -> Resul... | true |
832c3fc21abce5d1845b348bacd124647cf6e6b1 | Rust | Gopiandcode/rust-projects | /basics/src/extra.rs | UTF-8 | 785 | 3.734375 | 4 | [] | no_license | pub enum BinaryTree<T> {
Empty,
NonEmpty(Box<TreeNode<T>>)
}
struct TreeNode<T> {
element: T,
left: BinaryTree<T>,
right: BinaryTree<T>
}
impl<T> BinaryTree<T> {
pub fn new() -> Self {
BinaryTree::Empty
}
}
impl<T: Ord> BinaryTree<T> {
pub fn add(&mut self, value: T) {
... | true |
eee22e5ca3cb47fec6e95a0b3a9030660817891f | Rust | theonejb/advent-of-code-20 | /day12/src/tests.rs | UTF-8 | 4,452 | 3.375 | 3 | [
"MIT"
] | permissive | use crate::ferry_simulator::*;
use crate::ferry_simulator::Direction::{North, West, South, East};
use crate::ferry_simulator::RotationDirection::{Left, Right};
#[test]
fn test_rotation() {
assert_eq!(Ship::rotate(&North, Left, 90), West, "North to Left 90");
assert_eq!(Ship::rotate(&North, Left, 180), South, "... | true |
d9c4da9d35d4146dc11d86033c89c7d297c337a8 | Rust | mschorsch/raytracing-in-one-weekend | /src/camera.rs | UTF-8 | 2,116 | 3.171875 | 3 | [
"Unlicense"
] | permissive | use rand::prelude::*;
use crate::ray::Ray;
use crate::Vec3;
struct OrthoPlane {
u: Vec3,
v: Vec3,
#[allow(dead_code)]
w: Vec3,
}
pub struct Camera {
lower_left_corner: Vec3,
horizontal: Vec3,
vertical: Vec3,
origin: Vec3,
plane: OrthoPlane,
lens_radius: f32,
}
impl Camera {
... | true |
d454f6493e54b5785dc647185f58a2f7b2231f7a | Rust | garbein/rodent | /src/forms/site_setting_form.rs | UTF-8 | 706 | 2.796875 | 3 | [] | no_license | /// 配置表单
use validator::Validate;
use serde::{Serialize, Deserialize};
#[derive(Clone, Debug, Deserialize, Serialize, Validate)]
pub struct Form {
#[validate(length(min = 1, max = 32, message = "name length min 1 max 32"))]
pub name: String,
#[validate(length(min = 1, max = 32, message = "name length min 1... | true |
264ace3d2205a0adbd9ea94a614169be87699df2 | Rust | nimalar/Advent-of-Code | /2020/day21.rs | UTF-8 | 2,110 | 3.078125 | 3 | [] | no_license | use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::collections::HashMap;
fn main()
{
let args: Vec<String> = env::args().collect();
let filename = &args[1];
let mut f = File::open(filename).expect("File not found");
let mut contents = String::new();
f.read_to_string(&mut contents).expect("somethi... | true |
b5fae2fa941a966867e12758b5c23cb615c02b87 | Rust | kammitama5/Distracting_KATAS | /grasshopper_terminalgamemovefunction.rs | UTF-8 | 87 | 2.859375 | 3 | [] | no_license | fn move_hero(position: u32, roll: u32) -> u32 {
return (2 * roll) + position;
}
| true |
5cc423ef0d90dbce8911a3f655f210a3f77ad3b9 | Rust | bascarsija/advent_of_code_2019 | /day02/src/lib.rs | UTF-8 | 6,741 | 3.3125 | 3 | [] | no_license | pub mod intcode {
pub mod input {
use advent_of_code_2019::input;
pub fn input_op_codes() -> Vec<i64> {
let input = input::single_line_from_arg_file();
println!("input op codes: {}", input);
let mut op_codes = Vec::new();
for op_code in input.split(... | true |
0d39e3ced6f5b7d9968bbb1ba50df2d5a4e91872 | Rust | webrtc-rs/rtc | /sctp/src/shared.rs | UTF-8 | 2,458 | 3.0625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::Transmit;
/// Events sent from an Endpoint to an Association
#[derive(Debug)]
pub struct AssociationEvent(pub(crate) AssociationEventInner);
#[derive(Debug)]
pub(crate) enum AssociationEventInner {
/// A datagram has been received for the Association
Datagram(Transmit),
// New Association ident... | true |
66eda00b7aad06e955941f535e1162d20dd35ecf | Rust | nervosnetwork/ckb | /sync/src/tests/orphan_block_pool.rs | UTF-8 | 4,887 | 2.84375 | 3 | [
"MIT"
] | permissive | use ckb_chain_spec::consensus::ConsensusBuilder;
use ckb_systemtime::unix_time_as_millis;
use ckb_types::core::{BlockBuilder, BlockView, EpochNumberWithFraction, HeaderView};
use ckb_types::prelude::*;
use std::collections::HashSet;
use std::sync::Arc;
use std::thread;
use crate::orphan_block_pool::OrphanBlockPool;
f... | true |
4ec9e43dda9607fdcda7bc0e4b90a480d59ecb40 | Rust | amPerl/roadrash-cli | /src/actions/dat/pack.rs | UTF-8 | 2,096 | 2.78125 | 3 | [] | no_license | use anyhow::Context;
use clap::Clap;
use image::GenericImageView;
use std::collections::HashMap;
use std::path::Path;
use std::{fs::File, io::Write};
use crate::parsers::{DatTexture, Palette};
#[derive(Clap, Debug)]
pub struct PackOpts {
#[clap(short = 'i', long, about = "input directory")]
input_dir: String,... | true |
a1b08c7bc07580eeb50cd82830f9ff735a44c5ce | Rust | attilahorvath/advent-of-code-2017 | /day17/src/main.rs | UTF-8 | 551 | 2.96875 | 3 | [
"MIT"
] | permissive | extern crate day17;
use std::fs::File;
use std::io::prelude::*;
use day17::*;
fn main() {
let mut file = File::open("input.txt").expect("file not found");
let mut contents = String::new();
file.read_to_string(&mut contents).expect(
"error reading file",
);
let mut spinlock = Spinlock::n... | true |
1ac9e42d673bc750cbf1bba1c816617f311a17b7 | Rust | jauzeyimam/aoc19 | /src/day_two.rs | UTF-8 | 10,659 | 2.953125 | 3 | [] | no_license | use super::util;
use std::collections::HashMap;
use std::fs::File;
use std::io::{Error, ErrorKind};
use text_io::*;
pub struct DayTwo;
impl super::Solution for DayTwo {
fn solve(&self) -> Result<String, Error> {
let input = util::read_comma_delim(File::open("input/2.txt")?)?;
let result = format!... | true |
ebbec900ecb9060447b72936d44837da239d2dc0 | Rust | memoryruins/const_format_crates | /const_format_proc_macros/src/format_str_parsing/errors.rs | UTF-8 | 3,279 | 3.40625 | 3 | [
"Zlib"
] | permissive | use proc_macro2::Span;
use std::{
fmt::{self, Display},
ops::Range,
};
#[derive(Debug, PartialEq)]
pub(crate) struct ParseError {
pub(crate) pos: usize,
pub(crate) kind: ParseErrorKind,
}
#[derive(Debug, PartialEq)]
pub(crate) enum ParseErrorKind {
/// A `{` that wasn't closed.
UnclosedArg,
... | true |
eb8f2c7d09ac0c1b2b2ddf89173644adbb94199f | Rust | LaylBongers/damage-report | /projects/rpg-game/src/runtime.rs | UTF-8 | 10,012 | 2.515625 | 3 | [] | no_license | //#![allow(dead_code)]
use std::sync::{Arc};
use std::path::{PathBuf};
use cgmath::{Vector2, Point2};
use input::{Input, Button, Key, ButtonState, ButtonArgs};
use window::{Window, WindowSettings};
use slog::{Logger};
use calcium_flowy::FlowyRenderer;
use flowy::{Ui, Element};
use flowy::style::{Style, Position, Size... | true |
91be207f5a2b1c312f579d223597bb7ccbdcd1d3 | Rust | figo361/ckb | /test/src/specs/tx_pool/pool_reconcile.rs | UTF-8 | 1,296 | 2.5625 | 3 | [
"MIT"
] | permissive | use crate::node::waiting_for_sync;
use crate::{Node, Spec, DEFAULT_TX_PROPOSAL_WINDOW};
use log::info;
pub struct PoolReconcile;
impl Spec for PoolReconcile {
crate::setup!(num_nodes: 2);
fn run(&self, nodes: &mut Vec<Node>) {
let node0 = &nodes[0];
let node1 = &nodes[1];
info!("Gene... | true |
45c5541c803fc1e803e62c24ae635fc692ee8314 | Rust | joncv/tank | /engine/src/canvas.rs | UTF-8 | 1,238 | 2.8125 | 3 | [] | no_license | use Bitmap;
//画布
pub trait Canvas {
fn draw_image_repeat(&self, _image: &Bitmap, _x: i32, _y: i32, _width: i32, _height: i32) {}
fn draw_image_repeat_x(&self, _image: &Bitmap, _x: i32, _y: i32, _width: i32, _height: i32) {}
fn draw_image_repeat_y(&self, _image: &Bitmap, _x: i32, _y: i32, _width: i32, _heig... | true |
9ab4e2e092af73bc7443a8f4fce1cb7d12b090b1 | Rust | indiv0/xkcd-rs | /src/comics.rs | UTF-8 | 2,431 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | // Copyright (c) 2016-2017 Nikita Pekin and the xkcd_rs contributors
// See the README.md file at the top-level directory of this distribution.
//
// 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.o... | true |
e9d1af0255c020a332aa9edb6e2d18e338222a26 | Rust | PortalNetwork/graph-node | /graph/src/util/lfu_cache.rs | UTF-8 | 7,458 | 3.4375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use priority_queue::PriorityQueue;
use std::cmp::Reverse;
use std::fmt::Debug;
use std::hash::{Hash, Hasher};
// The number of `evict` calls without access after which an entry is considered stale.
const STALE_PERIOD: u64 = 100;
pub trait CacheWeight {
fn weight(&self) -> u64;
}
impl<T: CacheWeight> CacheWeight ... | true |
dd1309d552cf085998d06755ce59d0c992689af6 | Rust | ale64bit/aoc2020 | /13.2.rs | UTF-8 | 1,095 | 2.84375 | 3 | [] | no_license | use std::io::*;
fn euclid(m: i128, n: i128) -> (i128, i128) {
let (mut a, mut b) = (0, 1);
let (mut aa, mut bb) = (1, 0);
let (mut c, mut d) = (m, n);
while c % d != 0 {
let (q, r) = (c / d, c % d);
c = d;
d = r;
{
let t = aa;
aa = a;
... | true |
bd6c981055332786842548229b3a17c8d2c09f63 | Rust | atsamd-rs/atsamd | /boards/pygamer/examples/usb_poll.rs | UTF-8 | 2,245 | 2.609375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Makes the pygamer appear as a USB serial port loop back device.
//! Repeats back all characters sent to it, but in upper case.
#![no_std]
#![no_main]
#[cfg(not(feature = "panic_led"))]
use panic_halt as _;
use pygamer::{entry, hal, pac, Pins};
use hal::clock::GenericClockController;
use hal::prelude::*;
use pac:... | true |
13016d2c7ae977b9dd7eb1b00be0cb3578cd22d8 | Rust | tankofzion/winterfell | /crypto/src/hash/blake/tests.rs | UTF-8 | 958 | 2.6875 | 3 | [
"MIT"
] | permissive | // Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
use super::{Blake3_256, ElementHasher, Hasher};
use math::{fields::f62::BaseElement, FieldElement};
use rand_utils::rand_array;
#[test]
f... | true |
72cf7cef5a46401fc2813e7bda3a36134881729a | Rust | gadomski/cov | /cargo-cov/src/report.rs | UTF-8 | 12,310 | 3.46875 | 3 | [
"MIT"
] | permissive | //! Coverage report generation.
//!
//! # Template directory structure
//!
//! The coverage report produce two classes of files:
//!
//! * One summary page
//! * Source file pages, one page per source.
//!
//! `cargo cov` uses [Tera templates](https://github.com/Keats/tera#readme). Template files are stored using this
... | true |
8fca209d1630066b6b68e04d2ba4df946a62a7dd | Rust | IncompleteWorlds/07_GSaaS_Rust | /07_GSaaS_Rust/02_FDSaaS_R/src/backup/v7_20210722/process_message_task.rs | UTF-8 | 1,727 | 2.671875 | 3 | [] | no_license | /**
* (c) Incomplete Worlds 2020
* Alberto Fernandez (ajfg)
*
* FDS as a Service
* WaitForAnswerFuture
* It impliments a future that is only wake up when another task is completed
* and the 'completed' flag is changed
*
*/
use std::future::Future;
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll, Wa... | true |
32c082ec6ffde2319101535b0a73f88ba9b706bd | Rust | TheKevJames/juicyj | /src/error/weeder.rs | UTF-8 | 1,271 | 3.3125 | 3 | [] | no_license | use std::fmt;
use error::message::ErrorMessage;
/// An error struct generated by the weeder.
pub struct WeederError {
/// filename
pub filename: String,
/// ErrorMessage
pub message: ErrorMessage,
/// `format!`'ed representation of nearby `ParseNode`s
pub node: String,
}
impl WeederError {
... | true |
d72d3c689e0f8dd969d2d9f95fc1058610af8e77 | Rust | d-z-h/rust-guide | /examples/datetime/parse/examples/string.rs | UTF-8 | 832 | 2.875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime};
use chrono::format::ParseError;
fn main() -> Result<(), ParseError> {
let rfc2822 = DateTime::parse_from_rfc2822("Tue, 1 Jul 2003 10:52:37 +0200")?;
println!("{}", rfc2822);
let rfc3339 = DateTime::parse_from_rfc3339("1996-12-19T16:39:57-08:00"... | true |
32d022c728dfeccc0aeb10bfc3586987912c7d88 | Rust | treetertot/collapser-wfc | /src/tile.rs | UTF-8 | 4,235 | 2.65625 | 3 | [] | no_license | use std::iter::once;
use std::ops::Deref;
use std::slice::from_ref;
use collapser::cell::Working;
use crate::rules::Rules;
use rand::prelude::*;
pub type TileID = u16;
#[derive(Clone, Debug, PartialEq)]
pub struct SuperTile{
ids: Vec<TileID>,
scores: Weighted
}
impl Deref for SuperTile {
type Target = ... | true |
80c55df3d66415a7af1af42438ef4c954c0e98ce | Rust | truchi/tender | /src/grid/grid2d/iter/minor_mut.rs | UTF-8 | 2,056 | 3.0625 | 3 | [] | no_license | use super::*;
use std::{marker::PhantomData, ops::Range, slice::from_raw_parts_mut};
/// A mutable 1D iterator along the minor axis of an [`Grid2D`].
#[derive(Debug)]
pub struct MinorMut<'a, M, I, T, U> {
items: &'a mut [U],
index: usize,
phantom: PhantomData<(M, I, T)>,
}
impl<'a, M: Major, I, T: AsM... | true |
02a8730dff984468e575ee4f0b2c5175c9cc6c39 | Rust | wilfriedschmidt/adventofcode2018 | /aoc2018/src/day22.rs | UTF-8 | 4,237 | 3.453125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use util::*;
#[derive(Clone)]
struct BigNum
{
words:[u64;16],
}
impl Default for BigNum
{
fn default() -> BigNum
{
BigNum
{
words:[0;16]
}
}
}
fn mul_bignum(left:&BigNum, right:&BigNum) -> BigNum
{
let mut res:BigNum = BigNum::default();
for i in 0..16
... | true |
cd7ac77adfe6f0bafb9fea60af105fd22ead796f | Rust | Niedzwiedzw/minecraftrs | /mc/core/src/block/mod.rs | UTF-8 | 15,102 | 3.03125 | 3 | [] | no_license | use std::collections::HashMap;
use std::ptr::NonNull;
use std::fmt::Debug;
use once_cell::sync::OnceCell;
use bit_vec::BitVec;
use crate::tag::{TagType, TagTypeKey};
use crate::util::OpaquePtr;
mod state;
mod property;
mod util;
pub use state::*;
pub use property::*;
pub use util::*;
/// A basic block defined by ... | true |
a416f032db13065aab6534d4d1c1848b7884faa3 | Rust | inda21plusplus/mathm-chess | /chess-engine/src/piece/knight.rs | UTF-8 | 1,976 | 2.828125 | 3 | [] | no_license | use crate::{Board, Color, Position};
use super::util::threatened_at;
use super::Piece;
pub fn checks(at: Position, color: Color, board: &Board) -> bool {
let king_pos = board.get_king_position(color.other());
let delta_file = (king_pos.file() as i8 - at.file() as i8).abs();
let delta_rank = (king_pos.rank... | true |
3933ba5107bb67efedd1298b942f302e8f64dafc | Rust | nathanesau/data_structures_and_algorithms | /_courses/cmpt225/lecture06/builder_rust/src/main.rs | UTF-8 | 3,643 | 3.84375 | 4 | [] | no_license | enum GeometricShapeType {
CIRCLE,
SQUARE,
RECTANGLE,
}
impl std::fmt::Display for GeometricShapeType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match *self {
GeometricShapeType::CIRCLE => write!(f, "circle"),
GeometricShapeType::SQUARE => write!(f... | true |
5c7c4ee1be87d2169cd641d22e959608e3acede4 | Rust | ocornoc/bevy_either | /src/either_both.rs | UTF-8 | 9,265 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use super::*;
/// A type that contains either the [first](EitherBoth::Left) type, [second](EitherBoth::Right)
/// type, or [both](EitherBoth::Both).
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)]
pub enum EitherBoth<T, U> {
Left(T),
Right(U),
Both(T, U),
}
enum Matches {
Left,
... | true |
57710656d064be2d95b7906814b84dddc462092a | Rust | ganmacs/playground | /rust/msg/src/pack.rs | UTF-8 | 2,892 | 3.078125 | 3 | [] | no_license | use crate::value::{integer, Value};
use bytes;
pub trait Packer {
fn pack_bool(self, v: bool) -> Result<(), String>;
fn pack_nil(self) -> Result<(), String>;
fn pack_u64(self, v: u64) -> Result<(), String>;
fn pack_i64(self, v: i64) -> Result<(), String>;
fn pack_f64(self, v: f64) -> Result<(), Str... | true |
75356309ea8c32ef34191b4bc9cccd72118e729b | Rust | haodeng/rust_beginner | /src/vector.rs | UTF-8 | 2,901 | 4.40625 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | fn main() {
// hold elements of the i32 type
let v: Vec<i32> = Vec::new();
println!("{:?}", v);
// It’s more common to create a Vec<T> that has initial values, and Rust provides the vec! macro for convenience.
// Because we’ve given initial i32 values,
// Rust can infer that the type of v is V... | true |
f66068d5f7322968dd443717315777d34cc9679c | Rust | rvcampos/simple-dns | /simple-dns/src/dns/rdata/mod.rs | UTF-8 | 6,464 | 2.515625 | 3 | [
"MIT"
] | permissive | use super::{CharacterString, DnsPacketContent, Name, TYPE};
use core::fmt::Debug;
use std::collections::HashMap;
mod a;
mod aaaa;
mod hinfo;
mod minfo;
mod mx;
mod null;
mod soa;
mod srv;
mod wks;
pub use a::A;
pub use aaaa::AAAA;
use byteorder::{BigEndian, ByteOrder};
pub use hinfo::HINFO;
pub use minfo::MINFO;
pub ... | true |
26e85a9e191cc4eba6538c64a875535409122abd | Rust | ronlobo/rust_codingame | /puzzles/single_player/medium/marslander2/examples/main.rs | UTF-8 | 6,120 | 2.53125 | 3 | [
"MIT"
] | permissive | extern crate marslander2;
use marslander2::{game::*};
use std::time::Instant;
use marslander::genetic::{LanderWithGenomeAndResult, find_best_population, Genome, GenomeAndResult};
use marslander::lander::{Lander, FlyState, ControlCmd};
// A list of possible lander commands to reduce the search space
const COMMAND_SIZE... | true |
dff486a30e55e1964038d6293feeb69bc5d82cc3 | Rust | huxs/rust-raytracer | /src/math/ray.rs | UTF-8 | 315 | 3.046875 | 3 | [] | no_license | use crate::Vec3;
pub struct Ray {
pub origin: Vec3,
pub direction: Vec3,
}
impl Ray {
pub fn new(_origin: Vec3, _direction: Vec3) -> Ray {
Ray{origin:_origin, direction:_direction}
}
pub fn point_at_parameter(&self, t: f32) -> Vec3 {
self.origin + self.direction * t
}
}
| true |
909a8a4237e225831879150db402caecbb020be3 | Rust | JoelWilloughby/adventofcode_2020 | /src/aoc_06.rs | UTF-8 | 1,657 | 3.5 | 4 | [] | no_license |
pub struct Group {
any: u32,
all: u32,
}
impl Group {
pub fn new() -> Self {
Self { any: 0, all: !0 }
}
pub fn from_line(line: &str) -> Self {
let mut g = Self::new();
g.read_line(line);
g
}
pub fn read_line(&mut self, line: &str) {
let bytes = Str... | true |
adf9c172a2713e0f68b4f9d159c515382728268a | Rust | kannapoix/nakamoto | /common/src/p2p/peer.rs | UTF-8 | 7,827 | 3.296875 | 3 | [
"MIT"
] | permissive | //! Shared peer types.
use std::net;
use microserde as serde;
use bitcoin::network::address::Address;
use bitcoin::network::constants::ServiceFlags;
use crate::block::time::LocalTime;
/// Peer store.
///
/// Used to store peer addresses and metadata.
pub trait Store {
/// Get a known peer address.
fn get(&... | true |
e4a64dffc91e5cc538204cb09bbca4918f00122d | Rust | hortonhearsadan/system-dashboard | /src/cpu.rs | UTF-8 | 3,739 | 2.640625 | 3 | [] | no_license | use crate::fmt::{create_label, Celcify, Name, Percentify};
use crate::gpu::update_usage;
use crate::system::SystemInfo;
use cairo::{Context, Format, ImageSurface};
use gdk::prelude::IsA;
use gtk::{Align, BoxExt, GridExt, LabelExt, Orientation, StyleContextExt, Widget, WidgetExt};
pub struct CPUView {
container: gt... | true |
ec205a724ea7606cd0ac30a139c7c08e44fc21d6 | Rust | staccnft/metaplex | /rust/token-vault/program/src/state.rs | UTF-8 | 4,694 | 2.65625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown"
] | permissive | use {
crate::utils::try_from_slice_checked,
borsh::{BorshDeserialize, BorshSerialize},
solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey},
};
/// prefix used for PDAs to avoid certain collision attacks (https://en.wikipedia.org/wiki/Collision_attack#Chosen-prefix_collis... | true |
c4eb8b94c312db87e2c07738697fb29bd02772cb | Rust | hasanpasha/anterofit | /src/executor/threaded.rs | UTF-8 | 2,392 | 3.4375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Executors using background threads
use std::thread::{self, Builder};
use super::{Executor, Receiver};
/// An executor which uses multiple threads to complete jobs.
#[derive(Debug)]
pub struct MultiThread {
threads: usize,
}
impl MultiThread {
/// Create a new multithreaded executor using the given threa... | true |
d06269430844f4af48a251e944b163324bc8333e | Rust | rust9x/rust | /src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs | UTF-8 | 3,987 | 3.15625 | 3 | [
"MIT",
"BSD-3-Clause",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"NCSA"
] | permissive | #![deny(disjoint_capture_drop_reorder)]
//~^ NOTE: the lint level is defined here
// Test cases for types that implement a insignificant drop (stlib defined)
// `t` needs Drop because one of its elements needs drop,
// therefore precise capture might affect drop ordering
fn test1_all_need_migration() {
let t = (S... | true |
ac2c32c61c6aa7304d3259aca9e57a69ff90da1e | Rust | quietboil/sibyl | /src/stmt/cursor/blocking.rs | UTF-8 | 1,853 | 2.546875 | 3 | [
"MIT"
] | permissive | //! Blocking cursor
use parking_lot::RwLock;
use crate::{Cursor, Result, Rows, oci::*, stmt::cols::Columns};
impl<'a> Cursor<'a> {
/**
Returns rows selected by this cursor
# Example
```
use sibyl::Cursor;
# let session = sibyl::test_env::get_session()?;
let stmt = session.prepare("
... | true |
d9a725983ce8b30cd88a4656a77d02fae65de5df | Rust | marco-c/gecko-dev-comments-removed | /third_party/rust/regex/src/error.rs | UTF-8 | 1,650 | 3.046875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unicode",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::fmt;
use std::iter::repeat;
#[derive(Clone, PartialEq)]
pub enum Error {
Syntax(String),
CompiledTooBig(usize),
#[doc(hidden)]
__Nonexhaustive,
}
impl ::std::error::Error for Error {
#[allow(deprecated)]
fn description(&self) -> &str {
... | true |
09484bb693681a3ffc3562e7ba2cc3d481525e18 | Rust | karliss/bitflip | /src/game_ui.rs | UTF-8 | 33,558 | 2.71875 | 3 | [
"MIT"
] | permissive | use std::collections::HashSet;
use std::io::Write;
use termion::color;
use termion::event::{Event, Key};
use crate::encoding::Encoding;
use crate::gameplay::*;
use tgame::ui::*;
use tgame::vecmath::*;
enum GameState {
MainMenu,
Gameplay,
}
enum PanelType {
Top = 0,
Binary = 1,
Text = 2,
Righ... | true |
b36984426768aedf694024bfd57faa4aa03cf3ab | Rust | Mimikkk/leetcode-rust | /src/data_structures/tree/treenode.rs | UTF-8 | 357 | 3.078125 | 3 | [] | no_license | use crate::data_structures::tree::*;
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode<T> where T: Copy + Clone + Debug {
pub val: T,
pub left: Option<Node<T>>,
pub right: Option<Node<T>>,
}
impl<T> TreeNode<T> where T: Copy + Clone + Debug {
pub(crate) fn new(val: T) -> Self {
TreeNode { va... | true |
5042efcf29df5ab0ef93fde8dc0eab2e52a20c80 | Rust | sparkle-os/sparkle | /src/logger.rs | UTF-8 | 2,041 | 2.8125 | 3 | [
"BSD-3-Clause"
] | permissive | //! A basic console logging backend for the `log` crate.
use arch::x86_64::device::serial::COM1;
use arch::x86_64::interrupts;
use log;
use log::{Level, LevelFilter, Log, Metadata, Record, SetLoggerError};
static LOGGER: KernelLogger = KernelLogger;
/// Initializes the logger at kernel boot.
pub fn init() -> Result<... | true |
f7b57a704ad2ddf3935749e887eb6e7c71fdbe15 | Rust | mendrugory/learning-rust | /week_03/assignment_01/reverse/src/main.rs | UTF-8 | 376 | 3.515625 | 4 | [] | no_license | use std::io::{self, Write};
fn main() {
println!(" *** Reverse the String ***");
print!("> Type your String: ");
io::stdout().flush().unwrap();
let mut input = String::new();
io::stdin().read_line(&mut input).expect("Could not read line");
println!("{}", reverse(input))
}
fn reverse(s: String... | true |
de4ec285ef66eaf01f231e37becb69712625c4df | Rust | mvanbem/twin-stick-shooter | /twin-stick-shooter-core/src/bullet.rs | UTF-8 | 778 | 2.53125 | 3 | [
"MIT"
] | permissive | use legion::systems::CommandBuffer;
use legion::Entity;
use crate::hitbox::HitboxComponent;
use crate::resource::Time;
use crate::util::Timer;
#[derive(Clone, Debug)]
pub struct LifespanComponent(pub Timer);
#[derive(Clone, Debug)]
pub struct RemoveOnHitComponent;
#[legion::system(for_each)]
pub fn lifespan(
cm... | true |
f955eda2c412e3c02ea689ea3cee3e0887994f87 | Rust | iqlusioninc/yubihsm.rs | /src/mockhsm/error.rs | UTF-8 | 784 | 2.90625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! MockHSM errors
use crate::error::{BoxError, Context};
use thiserror::Error;
/// `MockHsm`-related errors
pub type Error = crate::Error<ErrorKind>;
/// Kinds of `MockHsm`-related errors
#[derive(Copy, Clone, Debug, Eq, Error, PartialEq)]
pub enum ErrorKind {
/// Access denied
#[error("access denied")]
... | true |
2acf00c5a430c5a481e1add79cb045602a786340 | Rust | azriel91/autexousious | /crate/character_selection/src/character_selection_state.rs | UTF-8 | 4,197 | 2.59375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::{fmt::Debug, marker::PhantomData};
use amethyst::{
ecs::{World, WorldExt},
GameData, State, StateData, Trans,
};
use application_event::AppEvent;
use application_state::{AppState, AppStateBuilder, AutexState};
use asset_selection_model::play::AssetSelectionEvent;
use character_selection_model::{
C... | true |
f65e2859c5804c13a91fab189b4ec94f5d2b60f2 | Rust | Daedalus359/proxygen | /build.rs | UTF-8 | 2,067 | 2.71875 | 3 | [
"MIT"
] | permissive | extern crate ease;
use std::env;
use std::path::Path;
use std::fs::OpenOptions;
use std::io::Read;
use std::io::Write;
use std::io::Seek;
use std::io::SeekFrom;
use std::cmp::Ordering;
use ease::{Url, Request};
#[derive(Debug, PartialEq)]
enum VersionStatus {
OutOfDate,
UpToDate,
}
fn get_allcards_version_st... | true |
76cd18762e4eef0519e5e80af9660e1d9e0aadb0 | Rust | psyomn/programming-exercise-solutions | /archive/challenge-0010/phone-rs/src/main.rs | UTF-8 | 586 | 3.328125 | 3 | [] | no_license | extern crate phone;
use std::env;
/// Valid phone numbers should be:
/// 1234567890,
/// 123-456-7890,
/// 123.456.7890,
/// (123)456-7890,
/// (123) 456-7890 (note the white space following the area code),
/// and 456-7890
fn main() {
let phone_number: Vec<String> = env::args().collect();
let number: &str = ... | true |
d6e986dd26cca7663288e2a1ccb2a78d5a5729a2 | Rust | Terkwood/toppa_drill | /src/states/ingame/base_state.rs | UTF-8 | 10,416 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | use amethyst::{
assets::{Handle, ProgressCounter},
core::{nalgebra::Vector3, transform::components::Transform},
ecs::prelude::*,
input::{is_close_requested, is_key_down},
prelude::*,
renderer::VirtualKeyCode,
ui::{UiEventType, UiPrefab},
};
use crate::{
entities,
resources::{
... | true |
3451fd3902242d2eaa274704c89aabb4d8d51cb0 | Rust | fits/try_samples | /rust/sample/alloc_layout_sample/src/main.rs | UTF-8 | 919 | 2.875 | 3 | [] | no_license |
use std::mem;
use std::alloc;
#[allow(dead_code)]
struct Data {
v1: i32,
v2: u8,
}
fn main() {
println!("usize align = {}", mem::align_of::<usize>());
println!("u8 align = {}", mem::align_of::<u8>());
println!("-----");
println!("{:?}", alloc::Layout::new::<i32>());
println!("-----");
... | true |
81c418422c78170de51eb8b41ab9712cdf43b8e4 | Rust | marcelbuesing/esp-idf-hal | /examples/blinky.rs | UTF-8 | 824 | 2.828125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Blinks an LED
//!
//! This assumes that a LED is connected to GPIO4.
//! Depending on your target and the board you are using you should change the pin.
//! If your board doesn't have on-board LEDs don't forget to add an appropriate resistor.
//!
use std::thread;
use std::time::Duration;
use embedded_hal::digital... | true |
1170394042855ec18ae3b42aac829d0c54d48779 | Rust | erglabs/common-tools-rs | /crates/settings/src/lib.rs | UTF-8 | 2,598 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | use std::{env, fmt::Debug};
use anyhow::bail;
use config::{Config, Environment, File};
use serde::Deserialize;
// todo write docs here
pub fn load_settings<'de, T: Deserialize<'de> + Debug>() -> anyhow::Result<T> {
let env = env::var("ENVIRONMENT").unwrap_or_else(|_| "development".to_string());
let exe = if... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.