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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f56393161a3c38c2287a82549fcbe49b90702381 | Rust | wildarch/toy-compiler | /src/mips/program.rs | UTF-8 | 1,949 | 3.265625 | 3 | [] | no_license | use std::fmt::{Display, Formatter, Error as FormatError};
use super::instruction::Instruction;
use super::label::Label;
use std::collections::HashMap;
#[derive(Debug)]
pub struct Program {
pub data: HashMap<Label, DataValue>,
pub text: HashMap<Label, Vec<Instruction>>,
}
#[derive(Debug)]
pub enum DataValue {... | true |
5d3d5ce03d41403467a8c87548e9d0685f743536 | Rust | jxs/rustw | /src/listings.rs | UTF-8 | 1,939 | 2.796875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2016 The Rustw Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// ex... | true |
23c323c55a4c63d64b14dcc1ba14b453930746cc | Rust | mayank-03/30-Days-Of-Code | /Day20/Solution.rs | UTF-8 | 1,632 | 3.6875 | 4 | [
"MIT"
] | permissive | use std::io;
fn main() {
let mut input_size = String::new();
let n;
match io::stdin().read_line(&mut input_size){
Ok(_) => {
match input_size.trim().parse::<usize>() {
Ok(number) => {
n = number;
}
Err(error) => {
... | true |
c9ac182d11ce93a49f93103b36cf6c0c9ba375cc | Rust | andrew-johnson-4/crates.io | /src/config.rs | UTF-8 | 7,993 | 2.734375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::publish_rate_limit::PublishRateLimit;
use crate::{env, uploaders::Uploader, Env, Replica};
#[derive(Clone, Debug)]
pub struct Config {
pub uploader: Uploader,
pub session_key: String,
pub gh_client_id: String,
pub gh_client_secret: String,
pub db_url: String,
pub replica_db_url: Opti... | true |
4969849583e5f53f72e157841200f79bb305f992 | Rust | heliumbrain/axum | /examples/async-graphql/src/starwars/mod.rs | UTF-8 | 4,069 | 2.875 | 3 | [
"MIT"
] | permissive | mod model;
use async_graphql::{EmptyMutation, EmptySubscription, Schema};
use model::Episode;
use slab::Slab;
use std::collections::HashMap;
pub use model::QueryRoot;
pub type StarWarsSchema = Schema<QueryRoot, EmptyMutation, EmptySubscription>;
pub struct StarWarsChar {
id: &'static str,
name: &'static str,... | true |
3746bdca8f19625a4e13289e516255f7fca4eeac | Rust | yuan-yuan-jia/Algorithms | /src/geometry.rs | UTF-8 | 2,934 | 3.328125 | 3 | [
"MIT"
] | permissive | pub mod angle_between_vectors;
pub mod geographical_coordinate;
pub mod tangent;
use std::ops::Sub;
pub const EPS: f64 = 1e-6;
pub struct Vec2D {
x: f64,
y: f64,
}
pub struct Vec3D {
x: f64,
y: f64,
z: f64,
}
impl Vec2D {
pub fn new(x: f64, y: f64) -> Self {
Self { x, y }
}
... | true |
dfc14cdeafeb231f1cf990658fe9c6bc3dd3da36 | Rust | Celeo/mixer_rust_wrappers | /src/rest/chat_helper.rs | UTF-8 | 3,064 | 3.453125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Helper for chat-related REST API endpoints.
use super::REST;
use failure::Error;
use log::debug;
/// Helper for chat-related REST API endpoints.
pub struct ChatHelper<'a> {
/// Reference to constructing REST struct
pub rest: &'a REST,
}
impl<'a> ChatHelper<'a> {
/// Get the channel ID for a username.... | true |
803ff0ca54951d6af4cd47083f95f295182d8ef7 | Rust | irevoire/game_of_life | /term/src/main.rs | UTF-8 | 2,006 | 2.578125 | 3 | [] | no_license | use core::Grid;
use std::io::{stdin, stdout, Write};
use termion::cursor::DetectCursorPos;
use termion::event::{Event, Key, MouseEvent};
use termion::input::{MouseTerminal, TermRead};
use termion::raw::IntoRawMode;
fn print(grid: &Grid) {
for line in grid.grid.iter() {
for cell in line.iter() {
... | true |
3eb43f8581a2e2cae27012937cb16b1796ea1f65 | Rust | mattgathu/aoc-19 | /src/7.rs | UTF-8 | 11,325 | 3.125 | 3 | [] | no_license | // --- Day 7: Amplification Circuit ---
//
// https://adventofcode.com/2019/day/7
//
use std::sync::mpsc;
type Program = Vec<i32>;
type Sequence = Vec<i32>;
type Memory = Vec<i32>;
#[derive(Debug, PartialEq)]
enum Opcode {
ADD,
MUL,
STO,
LOAD,
HLT,
JNZ,
JZ,
LT,
EQ,
}
impl Opcode {
... | true |
bbd2ecb2a328edbf0a70c433dc89c85edf8d7273 | Rust | khayyamsaleem/advent-of-code | /2022/src/day_10.rs | UTF-8 | 2,782 | 3.25 | 3 | [] | no_license | use crate::common;
use reqwest::Error;
#[derive(Debug,Clone)]
struct State {
x: i64,
}
fn run_instructions(initial_state: State, instructions: &str) -> Vec<State> {
instructions.trim().split("\n").into_iter().fold(vec![initial_state], |mut acc, instruction| {
let prev_state = acc.last().unwrap();
... | true |
437506a532c3c63028d8def3bf6d1622aaa98b13 | Rust | Arthamys/rust-json-api | /src/routes/documents.rs | UTF-8 | 980 | 2.75 | 3 | [] | no_license | use crate::repository::{DbConn, documents, revisions};
use crate::models::document::DocumentContent;
use rocket_contrib::json::{JsonValue, Json};
use rocket::response::status::Created;
use crate::error::ApiError;
#[get("/documents")]
pub fn get_all_documents(
conn: DbConn,
) -> Result<JsonValue, ApiError> {
le... | true |
c2ce68a67f8af8adcadac766d6e81bc21afa50a7 | Rust | MarcusTL12/AdventOfCode2016Rust | /src/day15.rs | UTF-8 | 2,390 | 3.078125 | 3 | [] | no_license | use std::{
fs::File,
io::{BufRead, BufReader},
iter,
};
use regex::Regex;
pub const PARTS: [fn(); 2] = [part1, part2];
fn egcd(a: i64, b: i64) -> (i64, i64, i64) {
if a == 0 {
(b, 0, 1)
} else {
let (g, x, y) = egcd(b % a, a);
(g, y - (b / a) * x, x)
}
}
fn mod_inv(x:... | true |
a5b203ad81fe3d67952cd054edc9f9661c3c6645 | Rust | rstrait/rustling-ontology | /grammar/ru/src/rules_number.rs | UTF-8 | 21,050 | 2.71875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::f64;
use rustling::*;
use rustling_ontology_values::dimension::*;
use rustling_ontology_values::dimension::Precision::*;
use rustling_ontology_values::helpers;
pub fn rules_numbers(b: &mut RuleSetBuilder<Dimension>) -> RustlingResult<()> {
b.rule_3("intersect (with and)",
number_check!(|numb... | true |
ffdfc998b270f85316c291b44bbda5de258380d1 | Rust | astral-sh/ruff | /crates/ruff_python_ast/src/call_path.rs | UTF-8 | 5,783 | 2.90625 | 3 | [
"BSD-3-Clause",
"0BSD",
"LicenseRef-scancode-free-unknown",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0"
] | permissive | use crate::{nodes, Expr};
use smallvec::{smallvec, SmallVec};
/// A representation of a qualified name, like `typing.List`.
pub type CallPath<'a> = SmallVec<[&'a str; 8]>;
/// Convert an `Expr` to its [`CallPath`] segments (like `["typing", "List"]`).
pub fn collect_call_path(expr: &Expr) -> Option<CallPath> {
//... | true |
2ae51557e786e30af79092190f131dd42f4aa7b1 | Rust | gnosis/reth | /crates/interfaces/src/devp2p.rs | UTF-8 | 1,564 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2021 Gnosis Ltd.
// SPDX-License-Identifier: Apache-2.0
use std::{
collections::{HashMap, HashSet},
sync::Arc,
};
pub type ProtocolIdType = [u8; 3];
pub type PeerId = usize;
pub type PeerCapability = HashMap<ProtocolId, HashSet<u8>>;
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone)]
pub enum Pr... | true |
6bf0726d35ec113cee0186e2d091037c0134051b | Rust | aa-ryan/Comp-Prog | /test.rs | UTF-8 | 558 | 2.859375 | 3 | [] | no_license | fn main() {
let mut first_string = String::from("");
std::io::stdin()
.read_line(&mut first_string)
.expect("String not found");
let mut second_string = String::from("");
std::io::stdin()
.read_line(&mut second_string)
.expect("String not found");
... | true |
c83a4b644c1e08e6f4d402637fefad5aaccaa3fb | Rust | silvercircle/rustplayground | /src/experiments/smart_pointers.rs | UTF-8 | 2,317 | 4.125 | 4 | [] | no_license | use std::ops::Deref;
struct Test {
x: i32,
name: String,
}
struct MyBox<T>(T);
impl<T> MyBox<T> {
fn new(x: T) -> MyBox<T> {
MyBox(x)
}
}
impl<T> Deref for MyBox<T> {
type Target = T;
fn deref(&self) -> &T {
&self.0
}
}
// drop is similar to destructors in C++. The code runs when
// the object... | true |
4be3c761f2c9c85e810ead47ae50eaea92a5a07b | Rust | Maskerad-rs/Maskerad_GameEngine | /maskerad_core/src/filesystem/filesystem.rs | UTF-8 | 8,077 | 2.84375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2017-2018 Maskerad Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except accord... | true |
0e85264e14841819fddc823229546a93adfebdb3 | Rust | Wandalen/OxiSynth | /core/src/synth/internal/gen.rs | UTF-8 | 1,028 | 3.03125 | 3 | [
"LGPL-2.1-only"
] | permissive | use crate::{
soundfont::generator::GeneratorType,
synth::{voice_pool::VoicePool, Channel},
};
/**
Change the value of a generator. This function allows to control
all synthesis parameters in real-time. The changes are additive,
i.e. they add up to the existing parameter value. This function is
similar to sending a... | true |
9a5ed4d184ce889031ff52cc441816cce0a82512 | Rust | CasualX/obfstr | /src/xref.rs | UTF-8 | 3,813 | 3.3125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::hint;
/// Obfuscates the xref to data reference.
///
/// ```
/// static FOO: i32 = 42;
/// let foo = obfstr::xref!(&FOO);
///
/// // When looking at the disassembly the reference to `FOO` has been obfuscated.
/// assert_eq!(foo as *const _, &FOO as *const _);
/// ```
///
/// This can be used for a more light... | true |
9478b2b852f342bb8e4bfd0ce4b854246290c4e8 | Rust | zekesonxx/aoc2020 | /src/day13.rs | UTF-8 | 738 | 2.78125 | 3 | [] | no_license |
#[aoc(day13, part1)]
fn part1(input: &str) -> usize {
let mut lines = input.split('\n');
let earliest = lines.next().unwrap().parse::<usize>().unwrap();
let line2 = lines.next().unwrap();
let busses: Vec<usize> = line2.split(',').map(|x| x.parse::<usize>()).flatten().collect();
println!("{}", earliest);
print... | true |
970032ddcd48b5e8258952ac25b0fca55b6cea8d | Rust | Lexikus/pandix | /core/src/sprite_management.rs | UTF-8 | 770 | 2.953125 | 3 | [] | no_license | extern crate image;
use std::collections::HashMap;
use image::DynamicImage;
pub(crate) enum Sprite {
None,
Image(DynamicImage),
Texture2d(u32)
}
pub(crate) struct SpriteManagement {
sprites: HashMap<String, Sprite>,
}
impl SpriteManagement {
pub(crate) fn new() -> Self {
Self {
... | true |
383c35a669341288f14a93293054c67060ba6e4d | Rust | pop/coding-exercises | /rust/examples/btree.rs | UTF-8 | 546 | 3.25 | 3 | [
"MIT"
] | permissive | use exercises;
use text_io::read;
fn main() {
println!("Creating a binary tree");
println!("Please enter an integer");
let input: isize = read!();
let mut the_tree = exercises::btree::BTree::new(input);
println!("Press Ctrl+C to quit modifying tree");
loop {
println!("{:#?}", the_tree);... | true |
ba9ed7f5d4850ce82df81187063bc4f828ae3ec7 | Rust | Rantanen/rust-directory-example | /src/directory/directory_module.rs | UTF-8 | 295 | 2.671875 | 3 | [] | no_license | //! This file specifies a `directory_module` module that
//! is located _within_ the `directory` module.
//!
//! This makes the full path of this module:
//! - `crate::directory::directory_module`
pub fn dir_fn() {
println!("Called crate::directory::directory_module::dir_fn");
}
| true |
1244b2bcebe0e18f0dd44f8a9d6dab5cd05f3695 | Rust | guillaume-be/rust-bert | /src/pipelines/ner.rs | UTF-8 | 15,293 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2019-present, the HuggingFace Inc. team, The Google AI Language Team and Facebook, Inc.
// Copyright (c) 2018 chakki (https://github.com/chakki-works/seqeval/blob/master/seqeval/metrics/sequence_labeling.py)
// Copyright 2019 Guillaume Becquin
// Licensed under the Apache License, Version 2.0 (the "License... | true |
9c67aae8309dfbc911fc06dc2cf214ead6b7b162 | Rust | Jesse-Runner/Rust_Assembler | /assembler/src/main.rs | UTF-8 | 15,811 | 3.234375 | 3 | [] | no_license | #![warn(clippy::all)]
extern crate byteorder;
use types::*;
use types::Val::*;
use self::Instr::*;
use types::Unop::*;
use types::Binop::*;
use self::Inst_or_label::*;
use std::env;
use std::str::FromStr;
use std::fs::File;
use std::fs;
use std::io::{BufRead, BufReader};
use std::collections::HashMap;
use byteorder::{... | true |
9ee58c8f1709a2e32f9972aef14bf937a2884e33 | Rust | Roba1993/yahoo-weather-rs | /src/error.rs | UTF-8 | 1,426 | 2.875 | 3 | [
"MIT"
] | permissive | use std::{io, num};
use hyper;
use serde_json;
use chrono;
quick_error! {
#[derive(Debug)]
pub enum Error {
Io(err: io::Error) {
from()
description("io error")
display("I/O error: {}", err)
cause(err)
}
Curl(err: hyper::Error) {
... | true |
bc031ff160974e5fd881f8613af45049204bb357 | Rust | graphql-rust/graphql-client | /graphql_client_codegen/src/constants.rs | UTF-8 | 697 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | pub(crate) const TYPENAME_FIELD: &str = "__typename";
pub(crate) const MULTIPLE_SUBSCRIPTION_FIELDS_ERROR: &str = r##"
Multiple-field queries on the root subscription field are forbidden by the spec.
See: https://github.com/facebook/graphql/blob/master/spec/Section%205%20--%20Validation.md#subscription-operation-defi... | true |
b05ce15ac00a8a0230cd5c582d50e41481fdc325 | Rust | odakaui/vocabulist | /src/database/mod.rs | UTF-8 | 11,032 | 2.90625 | 3 | [
"MIT"
] | permissive | use crate::Expression;
use rusqlite::{params, Connection};
use std::error::Error;
use std::path::PathBuf;
#[macro_use]
/// sql!(update_in_anki_for_expression, query, params=[tx: &Transaction, expression: &str, in_anki: bool])
macro_rules! sql {
($fn_name:ident, $query:expr, params=[$conn:ident:$conn_type:ty]) => {... | true |
88c9b96bc6472528546afd4b8380bc61d484c8d5 | Rust | 5225225/pendulum-rs | /src/lib.rs | UTF-8 | 4,755 | 3.625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive |
//! Data structures and runtimes for timer management.
//!
//! This library provides various data structures for managing coarse grain timers.
//!
//! #### Data Structures
//!
//! **Overview**
//!
//! We provide various data structures for timer management, each with their own tradeoffs and suited for different ap... | true |
e06bd0dd048406f94333a0ab9a9abb2db7d09ae7 | Rust | koehlma/momba | /engine/crates/momba-explore/src/model/types.rs | UTF-8 | 606 | 3.09375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Data structures for representing types.
use serde::{Deserialize, Serialize};
/// Possible data types of MombaIR values.
#[derive(Serialize, Deserialize, Eq, PartialEq, Hash, Clone, Debug)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE", tag = "type")]
pub enum Type {
/// A 64-bit signed integer.
Int64,
/... | true |
28efa0c79bb675dce30eb645669b1f6c8e49e2f2 | Rust | jwbuurlage/advent-of-code-2018 | /src/lib.rs | UTF-8 | 5,593 | 3.703125 | 4 | [
"MIT"
] | permissive | extern crate slab;
use std::io;
use slab::Slab;
use std::fmt;
use std::ops::{Index, IndexMut};
pub fn read_all<T: std::str::FromStr>() -> Vec<T> {
let mut xs = vec![];
loop {
let mut a_str = String::new();
match io::stdin().read_line(&mut a_str) {
Ok(x) => {
if x =... | true |
b7e4b65dc87573e63fde68f711027329cdf4eb08 | Rust | betrusted-io/xous-core | /kernel/src/platform/precursor/lcdpanic.rs | UTF-8 | 8,036 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | use crate::mem::MemoryManager;
use utralib::generated::*;
use xous_kernel::PID;
const FB_WIDTH_WORDS: usize = 11;
const FB_WIDTH_PIXELS: usize = 336;
const FB_LINES: usize = 536;
const FB_SIZE: usize = FB_WIDTH_WORDS * FB_LINES; // 44 bytes by 536 lines
// this font is... | true |
b27d63f036c46f191a5e4c425b1f47f76cf5ea9d | Rust | matt2xu/edge-rs | /src/response.rs | UTF-8 | 11,032 | 2.9375 | 3 | [
"MIT"
] | permissive | use hyper::header::{self, CookiePair as Cookie, ContentType, Header, SetCookie};
use hyper::status::StatusCode as Status;
use hyper::Headers;
use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value};
use serde_json::value as json;
use serde_json::value::ToJson;
use std::any::Any;
use std::boxed::Box;
use std::borrow... | true |
81139008e48a726515485b4bf8ff6ab9e428656a | Rust | kmein/slide | /src/main.rs | UTF-8 | 628 | 3.078125 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate structopt;
use std::io::{self, Read};
use structopt::StructOpt;
#[derive(StructOpt)]
#[structopt(name = "slide", about = "Generates sliding windows over words.")]
struct SlideOptions {
/// Window size
#[structopt(short = "n", long = "size")]
size: usize,
}
fn main() {
let op... | true |
6b1549b436afc773faaecab49a41466c0b026062 | Rust | theseus-os/Theseus | /applications/hull/src/lib.rs | UTF-8 | 13,985 | 2.703125 | 3 | [
"MIT"
] | permissive | //! `hull` is Theseus's shell for basic interactive systems operations.
//!
//! Just as the hull is the outermost layer or "shell" of a boat or ship,
//! this crate `hull` is the shell of the "Ship of Theseus" (this OS).
//!
//! Functionally, this is similar to bash, zsh, fish, etc.
//!
//! This shell will eventually s... | true |
980864d07a4d46f882861320e01eb851bad96849 | Rust | lpxxn/rust_example | /practice/r3array/src/main.rs | UTF-8 | 1,112 | 3.5 | 4 | [] | no_license | mod array_t;
fn main() {
let a1: [i32; 4] = [1, 2, 3, 4];
println!("{:?}", a1);
for v in &a1 {
println!("{}", v);
}
println!("index: {}", a1[2]);
let mut a2: [String; 5] = ["a".to_string(), "b".to_string(), "c123".to_string(), "d".to_string(), "e".to_string()];
println!("{:?}", a2... | true |
f3ff1a8afffa7837d80edee2c41e06131060597b | Rust | not-fl3/macroquad | /examples/platformer.rs | UTF-8 | 3,500 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use macroquad::prelude::*;
use macroquad_tiled as tiled;
use macroquad_platformer::*;
struct Player {
collider: Actor,
speed: Vec2,
}
struct Platform {
collider: Solid,
speed: f32,
}
#[macroquad::main("Platformer")]
async fn main() {
let tileset = load_texture("examples/tileset.png").await.unwr... | true |
b32c6d68301fc12fed882b4a51d954b452e2468c | Rust | taiki-e/futures-async-stream | /tests/ui/threads-safety.rs | UTF-8 | 561 | 2.578125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![feature(generators)]
use futures_async_stream::stream;
fn assert_send<T: Send>(_: T) {}
fn assert_sync<T: Send>(_: T) {}
#[stream(item = i32)]
pub async fn unboxed() {
yield 0;
}
#[stream(boxed, item = i32)]
pub async fn boxed() {
yield 0;
}
#[stream(boxed_local, item = i32)]
pub async fn boxed_local() ... | true |
1cce617fbbf6c4b5ce55f0b2bb2185c7ce74b13c | Rust | AtsukiTak/logfn | /tests/logfn_pre.rs | UTF-8 | 505 | 2.765625 | 3 | [] | no_license | use logfn::logfn;
#[logfn(Pre, Info, "execute {fn}")]
#[logfn(Post, Error, "failed to add: {ret:?}", if = "Option::is_none")]
#[logfn(Post, Info, "executed add", if = "Option::is_some")]
fn add(a: usize, b: usize) -> Option<usize> {
a.checked_add(b)
}
#[logfn(Pre, Info, "execute add")]
fn generics<T>(a: T) -> T
w... | true |
64bbbb59975b270b0985087e963e9c172228f801 | Rust | eldruin/pcf857x-rs | /src/devices/pcf8574.rs | UTF-8 | 5,637 | 2.734375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::cell;
use embedded_hal::blocking::i2c::{Read, Write};
pub use embedded_hal::digital::v2::OutputPin;
use crate::split_pins::pcf8574;
use crate::{Error, PinFlag, SlaveAddr};
macro_rules! pcf8574 {
( $device_name:ident, $device_data_name:ident, $default_address:expr ) => {
/// Device driver
... | true |
3ad3e5c6dd0fc4ecf46921d5bfd44f017ba95a7e | Rust | nolanderc/svg-renderer | /src/renderer/mod.rs | UTF-8 | 2,660 | 3.21875 | 3 | [] | no_license | mod path;
mod point;
use ::rectangle::Rectangle;
use self::path::Path;
use self::point::Point;
use ::img::{Image, Color};
pub struct Renderer {
paths: Vec<Path>
}
impl Renderer {
pub fn new() -> Renderer {
Renderer {
paths: Vec::new()
}
}
pub fn fill_rectangle(&mut sel... | true |
5028a09c60b5d52add5716faa430f87124b6a4a3 | Rust | cargo-crates/orm-rs | /src/nodes/node_filter_raw.rs | UTF-8 | 4,359 | 3.296875 | 3 | [] | no_license | use serde_json::{Value as JsonValue};
use crate::nodes::NodeAble;
#[derive(Clone, Debug)]
pub struct NodeFilterRaw {
raw_sql: String,
// placeholder values
condition: JsonValue,
r#type: String
}
impl NodeFilterRaw {
fn new(raw_sql: &str, condition: JsonValue, r#type: &str) -> Self {
Self {
... | true |
cfe61785911e9c391b394eaa3a0bf5d130cc013d | Rust | sagudev/AOC_2020 | /src/bin/day8.rs | UTF-8 | 3,750 | 3.4375 | 3 | [] | no_license | use aoc::read_data;
use std::collections::HashSet;
use std::convert::Infallible;
use std::error::Error;
use std::num::ParseIntError;
use std::str::FromStr;
#[derive(Debug, Clone)]
enum Operation {
Acc,
Jmp,
Nop,
}
impl FromStr for Operation {
type Err = Infallible;
// 4 shiny brown bags
fn fro... | true |
c67b53e0c59fcafbf5babdce323caa5d64e06b7f | Rust | ezBrandon/cs3520_TheLazyChefs | /Additional Code used/simplify_ingredients/src/main.rs | UTF-8 | 1,779 | 3.125 | 3 | [] | no_license | //use std::env;
use std::fs::File;
use std::io::Read;
use std::fs;
fn main() {
//creates string to save file to
let mut file_go_here = String::new();
//opens file, if cannot open file, return an error message. Replace **tecks.txt** with any .txt file location for a different file
let mut file = File::open("in... | true |
2fa00d0f62b7f45acdb80bca1d4b6fe6a0d56a6b | Rust | defvar/toy | /pkg/toy-api/src/task.rs | UTF-8 | 9,378 | 2.53125 | 3 | [
"MIT"
] | permissive | //! Model for task api.
use crate::common::{Format, ListObject, ListOption, ListOptionLike, SelectionCandidate};
use crate::graph::Graph;
use crate::selection::candidate::Candidates;
use crate::supervisors::SupervisorName;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use toy_core::metrics::EventId... | true |
00c823606161785cdca05eeb11b98b1057c9fc69 | Rust | actix/actix-web | /actix-web/src/types/payload.rs | UTF-8 | 21,409 | 3.21875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Basic binary and string payload extractors.
use std::{
borrow::Cow,
future::Future,
pin::Pin,
str,
task::{Context, Poll},
};
use actix_http::error::PayloadError;
use actix_utils::future::{ready, Either, Ready};
use bytes::{Bytes, BytesMut};
use encoding_rs::{Encoding, UTF_8};
use futures_core:... | true |
d98af5f00d59ec3358fcd4edaddcb44b85acb074 | Rust | josehu07/rust-learn | /06-packages/src/lib.rs | UTF-8 | 1,737 | 3.25 | 3 | [] | no_license | //
// Defines a struct also called `Rng`, but namespaced under `packages` instead of `rand`.
//
#[derive(Debug)]
pub struct Rng {
key : i32, // Private fields in public struct are still private.
pub val : String,
}
impl Rng {
pub fn new(key : i32, val : String) -> Rng {
Rng { //... | true |
9fe07adc649a46e30f96f9ae1665fa8146d3f773 | Rust | tommady/leetcode | /rust/src/p1837_sum_of_digits_in_base_k.rs | UTF-8 | 992 | 4.03125 | 4 | [] | no_license | // Given an integer n (in base 10) and a base k, return the sum of the digits of n after converting n from base 10 to base k. After converting, each digit should be interpreted as a base 10 number, and the sum should be returned in base 10. Example 1: Input: n = 34, k = 6 Output: 9 Explanation: 34 (base 10) expressed i... | true |
aba3d8e80fd08d077cbbc1c6032ee96c25532543 | Rust | JoaoBaptMG/PathRenderingLabRs | /path-processor/src/path/compiled_drawing.rs | UTF-8 | 5,159 | 2.75 | 3 | [
"MIT"
] | permissive | //------------------------------------------------------------------------------
// compiled_drawing.rs
//------------------------------------------------------------------------------
// A set of triangles, curve triangles and double curve triangles generated
// from a path
//------------------------------------------... | true |
3d0fc3771c135c43314b2d52cba95584f2dedafd | Rust | flashbuckets/rustful | /src/lib.rs | UTF-8 | 3,061 | 2.765625 | 3 | [
"MIT"
] | permissive | //!A light HTTP framework with REST-like features. The main purpose of Rustful
//!is to create a simple, modular and non-intrusive foundation for HTTP
//!applications. It has a mainly stateless structure, which naturally allows
//!it to run both as one single server and as multiple instances in a cluster.
//!
//!A new ... | true |
6bffd88e62a1e3d4188d837b0d41e0cd70fa26e0 | Rust | jxnu-liguobin/cs-summary-reflection | /rust-leetcode/src/leetcode_9.rs | UTF-8 | 997 | 3.5 | 4 | [
"Apache-2.0"
] | permissive | use std::ops::Index;
use crate::pre_structs::Solution;
///回文数
impl Solution {
//1.双指针,2.找规律,3.字符串,4.栈
pub fn is_palindrome(x: i32) -> bool {
//4ms
let mut n = x;
if n < 0 || (n != 0 && n % 10 == 0) {
return false;
} else {
let mut tmp = 0;
wh... | true |
e758268042d0de08be65cc6772575f8be2f96d67 | Rust | dannyn/ray_tracer | /src/canvas.rs | UTF-8 | 4,328 | 3.515625 | 4 | [] | no_license | use std::fs;
use std::f64;
use std::ops::{Add, Sub, Mul};
#[derive(Debug, Clone, Copy)]
pub struct Colour {
pub r: f64,
pub g: f64,
pub b: f64,
}
impl Colour {
pub fn new(r: f64, g: f64, b: f64) -> Colour {
Colour {r: r, g: g, b: b}
}
pub fn rgb_string(&self) -> String {
for... | true |
aa6db9f04cf0847ae3903de966454b69396029ab | Rust | sulabhkothari/SkRustLearn | /automated_tests/tests/integration_test2.rs | UTF-8 | 80 | 2.796875 | 3 | [] | no_license | use adder;
#[test]
fn it_adds_two() {
assert_eq!(22, adder::add_two(20));
} | true |
5ba32bceeaf24de84ebbcb88c9057bb9331942c5 | Rust | Javran/exercism-solutions | /rust/xorcism/src/lib.rs | UTF-8 | 1,790 | 3.640625 | 4 | [
"Apache-2.0"
] | permissive | use std::slice::Iter;
/// A munger which XORs a key with some data
#[derive(Clone)]
pub struct Xorcism<'a> {
key: &'a [u8],
pos: usize,
}
impl<'a> Xorcism<'a> {
/// Create a new Xorcism munger from a key
///
/// Should accept anything which has a cheap conversion to a byte slice.
pub fn new<Ke... | true |
b8d51aad2ba123527011a077531505d9bdc01c17 | Rust | Tobba/webrender | /src/aabbtree.rs | UTF-8 | 8,234 | 2.65625 | 3 | [] | no_license | use euclid::{Point2D, Rect, Size2D};
use internal_types::{CompiledNode, DisplayItemKey};
use resource_list::ResourceList;
use std::mem;
use types::NodeIndex;
use util;
pub struct AABBTreeNode {
pub split_rect: Rect<f32>,
pub actual_rect: Rect<f32>,
pub node_index: NodeIndex,
// TODO: Use Option + NonZ... | true |
41d301ea47bf63239138e1d1bfaa4bbb2b6e4df6 | Rust | jcornaz/autorel | /changelog/src/conventional_commit_parser.rs | UTF-8 | 2,012 | 2.5625 | 3 | [
"Unlicense",
"MIT"
] | permissive | use pest::Parser;
use super::*;
#[derive(Parser)]
#[grammar = "conventional_commit.pest"]
struct ConventionalCommitParser;
pub(crate) fn parse(commit_msg: &str) -> Option<Change> {
let commit = ConventionalCommitParser::parse(Rule::conventional_commit, commit_msg)
.ok()?
.next()?;
let mut re... | true |
78a6fa4fd5600d7843789e619d59986a8b2b14a5 | Rust | CaptainXX/RustLearning | /c3/c3_s2_variables/src/main.rs | UTF-8 | 543 | 3.6875 | 4 | [] | no_license | fn main() {
// An example of variables
let mut x = 5;
println!("The value of x is: {}", x);
x = 6;
println!("The value of x is: {}", x);
// An example of const
const MAX_POINTS: u32 = 1000_000;
println!("The const MAX_POINTS is: {}", MAX_POINTS);
// An example of shadowing
let ... | true |
8d0406d79d7528da94d8693aff0f0c0cc69f2655 | Rust | Yasushi/nlp100-rs | /src/bin/nlp49.rs | UTF-8 | 3,557 | 3.125 | 3 | [] | no_license | extern crate nlp100rs;
extern crate itertools;
use nlp100rs::chap05::neko;
use nlp100rs::Chunk;
use itertools::Itertools;
use std::ops::Add;
fn find_cross(x: &Vec<Chunk>, y: &Vec<Chunk>) -> Option<Chunk> {
for xc in x {
for yc in y {
if xc == yc {
return Some(xc.clone());
... | true |
0160f3262d7f9184eb22e4870f4469f5868e3433 | Rust | thaumant/eddie-js | /src/lib.rs | UTF-8 | 1,844 | 2.71875 | 3 | [
"MIT"
] | permissive | use std::cell::RefCell;
use eddie::slice::{Levenshtein, DamerauLevenshtein, Jaro, JaroWinkler};
thread_local! {
static LEVEN: Levenshtein = Levenshtein::new();
static DAMLEV: DamerauLevenshtein<u32> = DamerauLevenshtein::new();
static JARO: Jaro = Jaro::new();
static JARWIN: JaroWinkler = JaroWinkler:... | true |
744b43eb3532632e323ec2c589bf2b2fbe496a5f | Rust | a-kenji/relm4 | /relm4-macros/src/widgets/parse.rs | UTF-8 | 9,014 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use syn::{
braced, bracketed, parenthesized,
parse::{Parse, ParseBuffer, ParseStream},
parse_macro_input,
punctuated::Punctuated,
token, Expr, ExprMacro, Ident, Lit, Macro, Result, Token,
};
use crate::util;
use super::{Properties, Property, PropertyName, PropertyType, Tracker, Widget, WidgetFunc}... | true |
fdd7f9ee4ececde750d947778fce582861b331e1 | Rust | kamirr/kittyfb | /src/display_chunks.rs | UTF-8 | 900 | 2.6875 | 3 | [
"MIT"
] | permissive | use io::Write;
use std::io;
pub fn display_chunks(buf: &[u8], size: (usize, usize), bits_per_pixel: usize) -> io::Result<()> {
let stdout = std::io::stdout();
let mut handle = stdout.lock();
for k in 0..(buf.len() / 4096 + 1) {
let from = k * 4096;
let to = ((k + 1) * 4096).min(buf.len());... | true |
09393be8c9bab82802b02324fba7d65e08b89f31 | Rust | fzakaria/advent-of-code-2020 | /src/bin/day6.rs | UTF-8 | 2,123 | 3.0625 | 3 | [] | no_license | #![feature(iterator_fold_self)]
use advent_of_code_2020::UnsolvedError;
use std::collections::HashSet;
use std::error::Error;
use std::iter::FromIterator;
use std::str::Lines;
fn part1(input: &str) -> Result<(), Box<dyn Error>> {
let lines: Lines = input.lines();
let mut groups: Vec<Vec<&str>> = Vec::new();
... | true |
57513f2970a82b7615da87142d6f89e390f1d63a | Rust | fire-lib/fire-postgres | /fire-postgres/src/query/whr.rs | UTF-8 | 5,100 | 3.296875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive |
/// Possible operators
/// - = | != | < | <= | > | >= | LIKE | IN
/// - AND | OR
/// ## Example
/// ```
/// use fire_postgres::whr;
/// let a = &"val".to_string();
/// let b = &"val2".to_string();
/// let c: &Option<String> = &None;
/// let query = whr!(a AND "b" != b OR c);
///
/// assert_eq!(r#""a" = $1 AND "b" != ... | true |
1739511c766017dc0b2165a014affb568c92fab8 | Rust | Oyami-Srk/thirtyfour | /src/common/cookie.rs | UTF-8 | 3,147 | 3.140625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use chrono::{DateTime, TimeZone, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum SameSite {
Strict,
Lax,
None,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Cookie {
name: String,
value: serde_json::Value,
#[serde(skip_se... | true |
24e1c7ed91e21a8fc3c4c60f0c25fc77241679d2 | Rust | Blockstream/gdk | /subprojects/gdk_rust/gdk_registry/src/file.rs | UTF-8 | 1,421 | 3.046875 | 3 | [
"OpenSSL",
"MIT"
] | permissive | use std::fs::File;
use std::io::{self, BufReader, BufWriter, Seek};
use gdk_common::log::{info, log_enabled, Level};
use serde::{de::DeserializeOwned, Serialize};
use crate::Result;
pub(crate) fn read<V: DeserializeOwned>(file: &mut File) -> Result<V> {
file.seek(io::SeekFrom::Start(0))?;
if log_enabled!(Lev... | true |
ffea3a9f644b8dd0b00e181f50d042d667325127 | Rust | carstein/DataBrush | /src/painter.rs | UTF-8 | 5,871 | 3.078125 | 3 | [] | no_license | use colored::*;
use std::cmp;
use std::fmt::Write;
use crate::colors;
use crate::dataset;
#[derive(Copy, Clone)]
struct Brush {
data: u8,
color: colors::Colors,
}
struct Line {
address: usize,
fields: [Option<Brush>; 16],
}
impl Line {
fn new() -> Line {
Line {
address: 0,
... | true |
26ebd643a2f60dfd86f2aaac47968f6e2910c504 | Rust | Noah2610/noframe | /src/entity/traits/movement.rs | UTF-8 | 4,070 | 3.421875 | 3 | [
"MIT"
] | permissive | use ::geo::{
NumType,
point::Point,
rect::Rect
};
use super::{
super::Entity,
velocity::Velocity
};
pub enum Polarity {
Pos,
Neg,
Null
}
impl Polarity {
pub fn sign(&self) -> i8 {
match self {
Polarity::Pos => 1,
Polarity::Neg => -1,
Polarity::Null => 0
}
}
}
impl Fr... | true |
661f000f622c109e2fd1015b5553c5b175940b6d | Rust | DrKwint/good_lp | /tests/variables.rs | UTF-8 | 1,449 | 3.28125 | 3 | [
"LGPL-2.0-or-later",
"MIT"
] | permissive | use good_lp::{variables, Expression};
#[test]
fn complex_expression() {
let mut var1 = variables!();
let a = var1.add_variable();
let b = var1.add_variable();
let c = var1.add_variable();
let d = var1.add_variable();
assert_eq!(
9. * (a - b * 2.) + 4 * c / 2 - d,
9. * a + (-18.)... | true |
8defdb4ab445f6f95abbfa9d86862e63e8d2a370 | Rust | foxfriends/nomrs | /src/value/sequence/mod.rs | UTF-8 | 1,953 | 3.03125 | 3 | [] | no_license | mod map;
mod set;
mod list;
pub use self::map::NomsMap;
pub(crate) use self::map::Map;
pub use self::set::NomsSet;
pub(crate) use self::set::Set;
pub use self::list::NomsList;
pub(crate) use self::list::List;
use super::{NomsValue, Value, Ref, FromNoms, IntoNoms, Collection};
use hash::Hash;
use std::cmp::Ordering... | true |
66f754d5f6070b8cc9bfd6de22270a1998ac6cac | Rust | rust-lang/rustc-perf | /collector/compile-benchmarks/html5ever/src/util/str.rs | UTF-8 | 2,070 | 3.015625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Copyright 2014 The html5ever Project Developers. See the
// COPYRIGHT 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.org/licenses/MIT>,... | true |
2b583928964ea2dae740190c1bdfcea93257782f | Rust | Arcaelyx/rsh | /src/structs/mod.rs | UTF-8 | 255 | 2.90625 | 3 | [] | no_license | use std::env;
use std::path::PathBuf;
pub struct Directory {
pub home: PathBuf,
pub current: PathBuf
}
impl Directory {
pub fn new() -> Self {
Self {
home: env::home_dir().unwrap(),
current: env::current_dir().unwrap()
}
}
}
| true |
1779720a44a22178b9a1d18146141e0cbfc3fa88 | Rust | yanns/milli | /milli/src/heed_codec/roaring_bitmap/bo_roaring_bitmap_codec.rs | UTF-8 | 851 | 2.96875 | 3 | [
"MIT"
] | permissive | use std::borrow::Cow;
use byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt};
use roaring::RoaringBitmap;
pub struct BoRoaringBitmapCodec;
impl heed::BytesDecode<'_> for BoRoaringBitmapCodec {
type DItem = RoaringBitmap;
fn bytes_decode(mut bytes: &[u8]) -> Option<Self::DItem> {
let mut bitmap = ... | true |
838628433af1d24b4c17099f6bc67ace3a6b9c31 | Rust | mcgain/rust-learning | /ownership/src/main.rs | UTF-8 | 988 | 3.96875 | 4 | [] | no_license | fn main() {
// let x = 1;
let s = String::from("foo");
take_ownership(s);
// println!("x is {} and s is {}", x, s); // won't work because s has gone
let t = give_me_a_string();
println!("t = {}", t);
let u = give_and_return_a_string(t);
println!("after the return = {}", u);
let ... | true |
330868c6452fb2abd9ca790acaa583acf4c2d82f | Rust | dennisss/dacha | /pkg/common/src/vec_hash_set.rs | UTF-8 | 1,937 | 3.34375 | 3 | [
"Apache-2.0"
] | permissive | #[cfg(feature = "alloc")]
use alloc::string::String;
#[cfg(feature = "alloc")]
use alloc::vec::Vec;
use std::cmp::Eq;
use std::collections::HashMap;
use std::hash::Hash;
pub struct VecHashSet<K, V> {
keys: Vec<K>,
values: Vec<V>,
indices: HashMap<K, usize>,
}
impl<K: Hash + Eq + Clone, V> VecHashSet<K, V>... | true |
dbf83d3b65d0552e186a71f9eaf6a28cc190fd76 | Rust | RCasatta/rusty-paper-wallet | /src/bin.rs | UTF-8 | 794 | 3.015625 | 3 | [
"MIT"
] | permissive | use bitcoin::Network;
use log::error;
use rusty_paper_wallet::process;
use structopt::StructOpt;
/// Creates a paper wallet given a descriptor.
#[derive(StructOpt)]
struct Command {
/// The descriptor defining the spending script of the paper wallet{n}
/// Contains alias such as 'Alice' in place of keys that w... | true |
248aae86281388c06d902f1d067c75cdbb4713a4 | Rust | frodofine/webgl-matrix | /src/lib.rs | UTF-8 | 2,431 | 3.53125 | 4 | [
"MIT"
] | permissive | //! This is a lightweight matrix / vector library meant for usage with WebGL.
//!
//! At the core this library only consists of the traits `Matrix` and `Vector`. All implementations are optional features and can be added as needed.
//!
//! Available features:
//! * `Matrix4`: 4x4 matrix operations (includes *Vector4*)
... | true |
2363bc0e95aa6090ce30a203a769cb82459d3ad3 | Rust | virtuoushub/Theseus | /kernel/memfs/src/lib.rs | UTF-8 | 6,534 | 3 | 3 | [
"MIT"
] | permissive | #![no_std]
//! This crate contains an implementation of an in-memory filesystem backed by MappedPages from the memory crate
//! This crate allocates memory at page-size granularity, so it's inefficient with memory when creating small files
//! Currently, the read and write operations of the RamFile follows the interfa... | true |
05cff11986e2bf6c6dfa7ee3c36fbd4ba6425f32 | Rust | JonPulfer/advent_of_code | /2018/d7/src/sequencer.rs | UTF-8 | 5,149 | 3.359375 | 3 | [] | no_license | use regex::Regex;
lazy_static! {
static ref PAIRRE: Regex =
Regex::new(r"^Step\s(?P<child>\w)\s.*\sstep\s(?P<parent>\w)\s.*$").unwrap();
}
#[derive(Debug, Clone)]
/// Related pairing of a parent and child defining the directed link between two nodes.
struct Pair {
parent: String,
child: String,
}
... | true |
ef9d2a765977dbf2d81ccf523b009f37501373ba | Rust | Wumpf/MinigamesInRndLang | /rust_sdl2__tetris/src/gameboard.rs | UTF-8 | 6,516 | 2.765625 | 3 | [] | no_license | use std::cmp;
use sdl2;
use sdl2::rect::Point;
use blocks::*;
const NUM_BLOCKS_X: usize = 10;
const NUM_BLOCKS_Y: usize = 20;
/// Padding for block rendering at the borders in percent.
const BLOCK_RENDER_PADDING: f32 = 0.1;
pub struct Gameboard {
fields: [[Block; NUM_BLOCKS_X]; NUM_BLOCKS_Y],
piece: Option<Piec... | true |
fdf921489ad4963f7b1daac5e95671217322aed3 | Rust | DelSkayn/rquickjs | /core/src/value/convert/into.rs | UTF-8 | 14,952 | 2.78125 | 3 | [
"MIT"
] | permissive | use crate::{
convert::{IteratorJs, List},
value::Constructor,
Array, Ctx, Error, IntoAtom, IntoJs, Object, Result, StdResult, StdString, String, Value,
};
use std::{
cell::{Cell, RefCell},
collections::{BTreeMap, BTreeSet, HashMap, HashSet, LinkedList, VecDeque},
sync::{Mutex, RwLock},
time:... | true |
b91c60a8d514e4faab4fbfeb4d4eb98f1b0a1b14 | Rust | pbrook/aoc | /2020/21/src/main.rs | UTF-8 | 2,538 | 3.140625 | 3 | [] | no_license | use std::fs::File;
use std::io::{self, BufRead};
use std::collections::HashSet;
use std::collections::HashMap;
type SHash = HashSet<String>;
#[derive(Debug,Default)]
struct Food {
ingredients: SHash,
allergens: SHash,
}
fn parse_line(s: String) -> Food {
assert!(s.ends_with(')'));
let mut res = Food:... | true |
d9ac4e4cb74df47288a24fc2d943748bcc58355c | Rust | johnstonskj/rust-xml_dom | /src/shared/text.rs | UTF-8 | 22,362 | 3.140625 | 3 | [
"MIT"
] | permissive | use crate::shared::syntax::*;
use std::convert::TryFrom;
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::str::FromStr;
// ------------------------------------------------------------------------------------------------
// Public Types
// --------------------------------------------------------------... | true |
fcab91947f67f2e642e2e3474350ec6c31cdf083 | Rust | avborhanian/rust-clippy | /tests/ui/unnecessary_lazy_eval.rs | UTF-8 | 6,346 | 2.78125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //@run-rustfix
//@aux-build: proc_macros.rs
#![warn(clippy::unnecessary_lazy_evaluations)]
#![allow(clippy::redundant_closure)]
#![allow(clippy::bind_instead_of_map)]
#![allow(clippy::map_identity)]
#![allow(clippy::needless_borrow)]
#![allow(clippy::unnecessary_literal_unwrap)]
use std::ops::Deref;
extern crate proc... | true |
13c78df0627c50f02ec5dbd5bebf41bad43a45a8 | Rust | crodriguezvega/cryptopals | /set-1-basics/src/2-fixed-xor/lib.rs | UTF-8 | 762 | 3.296875 | 3 | [] | no_license | use shared::mappings;
pub fn xor(a: &str, b: &str) -> Result<String, &'static str> {
if !(a.is_ascii() && b.is_ascii()) {
Err("Input string(s) are not valid ASCII")
} else if a.len() != b.len() {
Err("Input strings are not the same length")
} else {
let a_numbers = to_bytes(a);
... | true |
e07a18b2b933d7e7298498bd0eeed2d2eac6b17b | Rust | klvnptr/rayt | /src/data/image.rs | UTF-8 | 4,516 | 3.578125 | 4 | [
"MIT"
] | permissive | use crate::data::colour::Colour;
use image::{DynamicImage, ImageBuffer, RgbImage};
pub struct Pixel {
row: u32,
col: u32,
colour: Colour,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Image {
width: u32,
height: u32,
pixels: Vec<Vec<Colour>>,
}
impl Pixel {
pub f... | true |
a91810e59c5c9ab5136422535c28114501843585 | Rust | 9uapaw/fordragon-backend | /server/src/game/components/movement.rs | UTF-8 | 789 | 2.9375 | 3 | [] | no_license | use crate::game::location::facing::Facing;
use crate::game::location::pos::Position;
use std::time::{Instant, Duration};
#[derive(Debug)]
pub struct Location {
pub position: Position
}
#[derive(Debug)]
pub struct Transformation {
pub facing: Facing,
pub speed: f32
}
pub struct MovementComponent {
pub... | true |
0adbb076dea45cc6f1a4aef472007f98de1c6eaf | Rust | mikialex/rendiation | /utils/abstract-tree/src/lib.rs | UTF-8 | 6,086 | 3.53125 | 4 | [] | no_license | mod iter;
pub use iter::*;
pub enum NextTraverseVisit {
/// exit tree traverse
Exit,
/// continue children
VisitChildren,
/// continue siblings, skip children
SkipChildren,
}
pub trait AbstractTreeNode {
fn visit_children(&self, visitor: impl FnMut(&Self));
fn children_count(&self) -> usize {
let ... | true |
c329474ed7c0e06a70419d21c6865c7acd4dc407 | Rust | vavrusa/rust-bpf | /src/bpf_linux.rs | UTF-8 | 5,365 | 2.671875 | 3 | [
"ISC"
] | permissive | use byteorder::{LittleEndian, ReadBytesExt};
use libc::{self, c_int, c_uint, c_void, setsockopt, socklen_t, SOL_SOCKET};
use std::io::Cursor;
use std::io::{Error, ErrorKind};
use std::mem::{forget, size_of_val};
use std::os::unix::io::RawFd;
use std::ptr::null;
#[repr(C)]
#[derive(Debug, Clone)]
pub struct Op {
co... | true |
8dfd78ed2394db6989d4bd30698ba235b7a1bb9a | Rust | asherkin/sm-ext-rs | /sm-ext-derive/src/lib.rs | UTF-8 | 33,373 | 2.734375 | 3 | [] | no_license | extern crate proc_macro;
use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree};
use quote::{format_ident, quote, quote_spanned, ToTokens, TokenStreamExt};
use syn;
use syn::spanned::Spanned;
/// Creates the entry point for SourceMod to recognise this library as an extension... | true |
4419df20f1577ba70c04abd18753e53691ee305d | Rust | swc-project/swc | /crates/swc_ecma_parser/src/parser/util.rs | UTF-8 | 9,870 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use swc_atoms::js_word;
use super::*;
use crate::token::Keyword;
impl Context {
pub(crate) fn is_reserved(self, word: &Word) -> bool {
match *word {
Word::Keyword(Keyword::Let) => self.strict,
Word::Keyword(Keyword::Await) => self.in_async || self.strict,
Word::Keyword(... | true |
a7714f8df93a7742f64284c7a85a84921643ed04 | Rust | Velfi/rust_game_gui_example | /src/main.rs | UTF-8 | 3,154 | 2.875 | 3 | [] | no_license | mod ui_layer;
mod widgets;
use ggez::{
conf, event, event::MouseButton, event::MouseState, graphics, graphics::Drawable, Context,
GameResult,
};
use ui_layer::UiLayer;
use widgets::Button;
fn main() {
let c = conf::Conf::new();
let ctx = &mut Context::load_from_conf("super_simple", "ggez", c).unwrap()... | true |
40688ce791a08af0b7974220dfbf97616ad95ee6 | Rust | JAD3N/mc-server | /server/src/network/listener.rs | UTF-8 | 1,914 | 2.65625 | 3 | [
"MIT"
] | permissive | use crate::server::{ServerShared, ServerRequest};
use crate::core::MappedRegistry;
use super::protocol::Protocol;
use super::{Worker, Connection};
use std::net::SocketAddr;
use std::io;
use std::sync::Arc;
use tokio::net::TcpListener;
use flume::Sender;
pub struct Listener {
server_tx: Sender<ServerRequ... | true |
88e3944b440e84a936ec18c575faa6512e997f42 | Rust | rdesarz/rust-http-server | /src/main.rs | UTF-8 | 606 | 2.71875 | 3 | [
"MIT"
] | permissive | use http_server::connection::tcp::TcpServerConnection;
use http_server::http::server::Server;
use std::env;
use std::net::SocketAddr;
use std::str::FromStr;
fn main() {
let args: Vec<String> = env::args().collect();
let socket = &args[1];
// Create connection for the server
let tcp_server_connection ... | true |
e935f3e7ed0d7a70c05f64f5e7a263e6e7e89726 | Rust | conradlo/rusty-leetcode | /src/_0112_path_sum.rs | UTF-8 | 6,162 | 3.03125 | 3 | [] | no_license | /*
* @lc app=leetcode id=112 lang=rust
*
* [112] Path Sum
*/
// @lc code=start
// Definition for a binary tree node.
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
impl TreeNode {
#[inline]
... | true |
83f1a09b79475125cff18100d356dae79b03550a | Rust | emeric-martineau/fapi | /src/main.rs | UTF-8 | 9,006 | 2.640625 | 3 | [
"MIT"
] | permissive | extern crate rocket;
extern crate serde_json;
/*
#[cfg(test)]
mod tests;
use std::{io, env};
use std::fs::File;
use rocket::{Request, Handler, Route, Data, Catcher};
use rocket::http::{Status, RawStr};
use rocket::response::{self, Responder, status::Custom};
use rocket::handler::Outcome;
use rocket::outcome::IntoOut... | true |
4307e804ec820c6a8182c8eec6254c16aff0756b | Rust | bIgBV/rust-robin | /src/main.rs | UTF-8 | 2,781 | 2.875 | 3 | [] | no_license | extern crate bufstream;
extern crate rand;
/*
The purpose of this module is to alleviate
imports of many common I/O traits by adding
a glob import to the top of I/O heavy modules.
http://doc.rust-lang.org/std/io/prelude/
*/
use std::io::prelude::*;
use std::io;
use std::net::{TcpListener, TcpStream};
... | true |
2109bf79f2f4df6049c386044d819eb6666fca3a | Rust | zhouyuxiang0/facade | /ui/src/widgets/container.rs | UTF-8 | 1,255 | 2.671875 | 3 | [] | no_license | use crate::widgets::{self, Reqs, View, Widget, WidgetModel};
use protocol::Container;
use yew::{html, Properties};
pub type ContainerWidget = WidgetModel<Model>;
pub struct Model {
container: Container,
}
#[derive(Properties, PartialEq, Clone)]
pub struct Props {
#[props(required)]
pub container: Contain... | true |
f93bd96c1f058e63bd99f07c24915a1d38c21a7d | Rust | Atul9/memory-profiler | /cli-core/src/vecvec.rs | UTF-8 | 4,627 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use std::iter::FusedIterator;
use std::cmp::Ordering;
use std::u32;
#[derive(Default)]
pub struct VecVec< K, T > {
index: Vec< (K, u32, u32) >,
storage: Vec< T >
}
impl< K, T > VecVec< K, T > {
#[inline]
pub fn new() -> Self {
VecVec {
index: Vec::new(),
storage: Vec::n... | true |
ab0aa8a99cafc355eb6a06d19ea0c66856879c7e | Rust | marco-c/gecko-dev-wordified | /third_party/rust/pkg-config/src/lib.rs | UTF-8 | 31,853 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | /
/
!
A
build
dependency
for
Cargo
libraries
to
find
system
artifacts
through
the
/
/
!
pkg
-
config
utility
.
/
/
!
/
/
!
This
library
will
shell
out
to
pkg
-
config
as
part
of
build
scripts
and
/
/
!
probe
the
system
to
determine
how
to
link
to
a
specified
library
.
The
/
/
!
Config
structure
serves
as
a
method
of
co... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.