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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3c3f5298bf09ebdb287e7b369527b822558198cc | Rust | wshatch/lisp_compiler | /src/nom_parse_funcs.rs | UTF-8 | 3,310 | 3.078125 | 3 | [] | no_license | #![allow(dead_code)]
use nom::{digit, multispace};
use std::rc::Rc;
use token::{Token, LispyVal, LispyRet};
/*
number : [0-9]
symbol : number | alpha | operator | comparator
comparator : < | > | == | >= | <= | != | & | \|
operator : '+' | '-' | '*' | '/'
expr : <symbol> | <operator> | <s... | true |
a935c9b59cc9913920650d47ee172cfad1648d56 | Rust | notdanilo/surface | /src/surface/manager.rs | UTF-8 | 2,896 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use winit::event_loop::{EventLoop, ControlFlow};
pub struct SurfaceManager<T: 'static> {
event_loop: EventLoop<T>
}
impl<T: 'static> From<EventLoop<T>> for SurfaceManager<T> {
fn from(event_loop: EventLoop<T>) -> Self {
Self { event_loop }
}
}
impl Default for SurfaceManager<()> {
fn default(... | true |
c0dc950f38430da7fa861ec39598a1210300c15e | Rust | vandenoever/amxml | /src/xpath_impl/eval.rs | UTF-8 | 125,696 | 2.90625 | 3 | [] | no_license | //
// xpath_impl/eval.rs
//
// amxml: XML processor with XPath.
// Copyright (C) 2018 KOYAMA Hiro <tac@amris.co.jp>
//
use std::collections::HashMap;
use std::cmp::Ordering;
use std::error::Error;
use std::f64;
use std::i64;
use std::str::FromStr;
use std::usize;
use dom::*;
use xmlerror::*;
use xpat... | true |
88552dde71303fcd7d94b0a06d29380801d414be | Rust | brunoczim/mursic | /src/player.rs | UTF-8 | 646 | 2.609375 | 3 | [
"MIT"
] | permissive | mod rodio;
use crate::source::Source;
#[derive(Debug)]
pub struct Player {
#[cfg(target_arch = "wasm32")]
backend: (),
#[cfg(not(target_arch = "wasm32"))]
backend: rodio::Rodio,
}
impl Player {
pub fn new() -> Option<Self> {
Backend::new().map(|backend| Player { backend })
}
pub ... | true |
0008de0a1f776dc3e7bd965adba59b9e855cb228 | Rust | JiahaiHu/kv-server | /src/store/engine/mod.rs | UTF-8 | 3,339 | 3.15625 | 3 | [] | no_license | pub mod log;
use std::collections::{BTreeMap, HashMap};
use std::fs::OpenOptions;
use std::io::BufRead;
use std::io::BufReader;
use std::sync::Arc;
use std::sync::Mutex;
use super::{Engine, Key, Value};
use log::{Log, LogType};
const LOG_PATH: &'static str = "kv.log";
#[derive(Clone)]
pub struct Kvdb {
pub db: ... | true |
e53a324244371ea6ca689ee16a189f7c623d6de5 | Rust | mikialex/rendiation | /scene/raytracing/src/sampling/sampler.rs | UTF-8 | 4,437 | 2.6875 | 3 | [] | no_license | use std::sync::Arc;
use rand::{prelude::SliceRandom, rngs::ThreadRng, Rng};
use rendiation_algebra::Vec2;
/// https://www.pbr-book.org/3ed-2018/Sampling_and_Reconstruction/Sampling_Interface#fragment-SamplerInterface-2
/// Because sample values must be strictly less than 1,
/// OneMinusEpsilon, that represents the l... | true |
9fc6ed07ed54529b7e3d496885acfa6aaddc8b78 | Rust | abhijat/jumbo | /src/main.rs | UTF-8 | 1,759 | 3.171875 | 3 | [] | no_license | use std::env;
use std::fs;
use std::io;
use std::path;
fn cumulative_size(path: &path::Path, mut dir_sizes: &mut Vec<(String, u64)>) -> io::Result<u64> {
if path.is_dir() {
let mut total_size: u64 = 0;
let entries = path.read_dir();
if entries.is_err() {
println!("failed to rea... | true |
b1646a282684d468446442f6b12240ba058dbd80 | Rust | deliveroo/prost | /prost-derive/src/options.rs | UTF-8 | 2,389 | 2.796875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use anyhow::{bail, Error};
use syn::{Attribute, Lit, Meta, MetaNameValue};
use crate::field::{bool_attr, prost_attrs, set_option};
pub struct Options {
pub debug: bool,
pub default: bool,
pub merge: bool,
pub proto: ProtoVersion,
}
#[derive(Debug, PartialEq)]
pub enum ProtoVersion {
Proto2,
P... | true |
c8afa84d8679b84cd30d59942711ecee6c12d0aa | Rust | VanillaBrooks/args_into | /args_into/src/generics.rs | UTF-8 | 5,184 | 3.015625 | 3 | [] | no_license | use syn::punctuated::Punctuated;
use syn::FnArg;
use syn::GenericArgument;
use syn::GenericParam;
use syn::Ident;
use syn::Path;
use syn::PathSegment;
use syn::TypeParam;
use syn::TypeParamBound;
/// Find all of the types in the function arguments and return them as a GenericArgument type
/// to be used as `T` in `Int... | true |
b22907704b59d4004a2ae4cdbfef0bdcd28ed3e4 | Rust | ohmountain/blog-cli | /src/arg/mod.rs | UTF-8 | 1,936 | 3.421875 | 3 | [] | no_license | use std::env;
pub enum Method {
CreateType,
CreatePost,
Edit,
Show,
Delete,
Search,
Error
}
pub fn get_args() -> Vec<String> {
env::args().skip(1).map(|x|x).collect()
}
pub fn print_help() {
println!(" ");
println!("blog-cli usage");
println!(" ");
println!(" ... | true |
fff49377df33f2e2f343f338137f8d4e0a71b8af | Rust | gdepuydt/fuzzoz | /src/core_requirements.rs | UTF-8 | 3,826 | 3.03125 | 3 | [] | no_license | // was temporarily removed
#[inline(always)]
#[cfg(target_arch = "x86_64")]
unsafe fn memcpy_int(dest: *mut u8, src: *const u8, n: usize) -> *mut u8 {
asm!("rep movsb",
inout("rcx") n => _,
inout("rdi") dest => _,
inout("rsi") src => _);
dest
}
#[no_mangle]
#[cfg(target_arch = "x86_64"... | true |
1d6bb7b4ee9d6d0c1c65d894f7d94fc8346cff4d | Rust | timsims1717/RustADE | /src/game/gamestate.rs | UTF-8 | 4,052 | 3.1875 | 3 | [] | no_license |
use obj::DamageType;
use obj::item::Item;
use obj::location::Location;
use obj::player::Player;
use parsing::grammar::ItemNode;
use parsing::DirectionType;
pub struct GameState {
pub break_control: bool,
player: Player,
locations: Vec<Location>,
}
impl GameState {
/*
Creates a GameState instance.
*/
pub fn n... | true |
69d98c2516904166cb6108e7ea54f2ce717adce4 | Rust | harrybrwn/calc | /src/main.rs | UTF-8 | 900 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive | use std::env;
use std::io::{self, Error, ErrorKind, Write};
use calc::exec;
fn interpreter() -> Result<(), Error> {
let stdin = io::stdin();
let mut stdout = io::stdout();
let mut s = String::new();
loop {
print!(">>> ");
stdout.flush()?;
stdin.read_line(&mut s)?;
if... | true |
93c431fc1fbc18e322bde3be87ad88d82a7a4a61 | Rust | pkafma-aon/LeetCode-Rust | /src/excel_sheet_column_title.rs | UTF-8 | 560 | 3.375 | 3 | [
"WTFPL"
] | permissive | impl Solution {
pub fn convert_to_title(mut n: i32) -> String {
let mut ret = String::new();
while n != 0 {
n -= 1;
ret.push((b'A' + (n % 26) as u8)as char);
n /= 26;
}
ret.chars().rev().collect()
}
}
pub struct Solution;
#[cfg(test)]
mod tes... | true |
d86abbf3e2f7a9341eec7d16f66ddd0eb5a58371 | Rust | edmccard/machine_int | /src/lib.rs | UTF-8 | 21,243 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2018 Ed McCardell
//
// 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
// except according to... | true |
83bedf602e22b99703501ffc735fb58adf1f14b4 | Rust | hamadakafu/kyopro | /src/bin/typical90_34.rs | UTF-8 | 1,234 | 2.890625 | 3 | [] | no_license | use std::cmp::Reverse;
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use itertools::Itertools;
use whiteread::parse_line;
const ten97: usize = 1000_000_007;
/// 2の逆元 mod ten97.割りたいときに使う
const inv2ten97: u128 = 500_000_004;
/// しゃくとり法,尺取り法
/// ```
/// let a = 1;
/// ```
fn main() {
let (n, ... | true |
7af0f66dbcd71cc1316ecf58eb3f389dad7f0661 | Rust | kenchan/competitive_programming | /atcoder/abc276/src/bin/a.rs | UTF-8 | 243 | 2.671875 | 3 | [] | no_license | use proconio::input;
fn main() {
input! {
s: String,
}
for (i ,c) in s.chars().rev().enumerate() {
if c == 'a' {
println!("{}", s.len() - i);
return;
}
}
println!("-1");
}
| true |
113393c7070b983d73d73ae8c6b3d5606c131d2c | Rust | imos/icfpc2021 | /src/ugougo.rs | UTF-8 | 3,891 | 2.640625 | 3 | [
"MIT"
] | permissive | use std::iter::*;
use crate::*;
use rand;
use rand::*;
const DIRS: [Point; 4] = [
P::<i64>(1, 0),
P::<i64>(0, 1),
P::<i64>(-1, 0),
P::<i64>(0, -1),
];
pub fn ugougo(problem: &Input, pose: &Output, cycles: i32) -> (Output, i32) {
let Input {
hole,
figure: Figure {
edges,
vertices: original_vertices,
... | true |
63fc5f4811fff91e877649278ff6a241d7304bd3 | Rust | metacall/core | /source/loaders/rs_loader/rust/compiler/src/memory.rs | UTF-8 | 1,654 | 2.53125 | 3 | [
"Python-2.0",
"GPL-2.0-or-later",
"MPL-1.1",
"NCSA",
"LicenseRef-scancode-proprietary-license",
"GPL-1.0-or-later",
"BSD-3-Clause",
"MPL-2.0",
"Ruby",
"BSD-2-Clause",
"MIT",
"Apache-2.0"
] | permissive | use crate::{compile, CompilerState, RegistrationError, Source};
use std::{ffi::c_void};
use crate::{registrator, DlopenLibrary};
#[derive(Debug)]
pub struct MemoryRegistration {
pub name: String,
pub state: CompilerState,
pub dlopen: Option<DlopenLibrary>,
}
impl MemoryRegistration {
pub fn new(name:... | true |
8e64f65274c749732dfb9fff9faf2abc43b5ff85 | Rust | AntonGepting/tmux-interface-rs | /src/commands/windows_and_panes/last_window_tests.rs | UTF-8 | 797 | 2.875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #[test]
fn last_window() {
use crate::LastWindow;
use std::borrow::Cow;
// Select the last (previously selected) window
//
// # Manual
//
// tmux ^0.8:
// ```text
// last-window [-t target-session]
// (alias: last)
// ```
let last_window = LastWindow::new();
#[cfg(fe... | true |
943fe5719ea5500b749aa9d3f216d74e77553546 | Rust | divagant-martian/lighthouse | /slasher/tests/wrap_around.rs | UTF-8 | 2,592 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use slasher::{
test_utils::{indexed_att, logger},
Config, Error, Slasher,
};
use tempdir::TempDir;
use types::Epoch;
#[test]
fn attestation_pruning_empty_wrap_around() {
let tempdir = TempDir::new("slasher").unwrap();
let mut config = Config::new(tempdir.path().into());
config.validator_chunk_size ... | true |
c4d3e49da23f22d9f3288af28c2fa89da3aa537d | Rust | 0x192/iced_aw | /src/native/wrap.rs | UTF-8 | 15,772 | 3.21875 | 3 | [
"MIT"
] | permissive | //! A widget that displays its children in multiple horizontal or vertical runs.
//!
//! *This API requires the following crate features to be activated: `wrap`*
use std::marker::PhantomData;
use iced_native::{
event,
layout::{self, Limits, Node},
overlay, Align, Clipboard, Element, Event, Hasher, Layout,... | true |
9e27664cf1ecfd1f645abe52fed3f5973257ea5e | Rust | agmcleod/adventofcode-2018 | /22/src/tile_type.rs | UTF-8 | 344 | 3.484375 | 3 | [
"MIT"
] | permissive | #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum TileType {
Rocky,
Wet,
Narrow,
}
impl TileType {
pub fn from_num(num: usize) -> TileType {
match num {
0 => TileType::Rocky,
1 => TileType::Wet,
2 => TileType::Narrow,
_ => panic!("Invalid numb... | true |
4f47226a8459dee5b7572955216cfbd5fe175443 | Rust | liljencrantz/crush | /src/lang/data/struct.rs | UTF-8 | 8,550 | 2.546875 | 3 | [
"MIT"
] | permissive | use crate::lang::errors::{error, CrushError, CrushResult};
use crate::lang::pipe::CrushStream;
use crate::lang::data::table::ColumnType;
use crate::lang::data::table::Row;
use crate::lang::value::Value;
use crate::lang::value::ValueType;
use crate::util::identity_arc::Identity;
use crate::util::replace::Replace;
use ch... | true |
189b06a184e8e3510da4fce898dd9ddd750de484 | Rust | galenelias/AdventOfCode_2017 | /src/main.rs | UTF-8 | 2,037 | 2.953125 | 3 | [] | no_license | extern crate clap;
extern crate regex;
extern crate serde_json;
extern crate chrono;
#[macro_use]
extern crate serde_derive;
use clap::{Arg,Command};
mod stats;
mod day1;
mod day2;
mod day3;
mod day4;
mod day5;
mod day6;
mod day7;
mod day8;
mod day9;
mod day10;
mod day11;
mod day12;
mod day13;
mod day14;
mod day15;... | true |
3e7f83af021774511ac98cce857ecbae31a20782 | Rust | skrap/aoc_rust_2018 | /src/bin/8.rs | UTF-8 | 1,651 | 3.140625 | 3 | [] | no_license | extern crate regex;
struct Node {
children: Vec<Node>,
meta: Vec<i32>,
}
impl Node {
fn new() -> Node {
Node { children: Vec::new(), meta: Vec::new() }
}
fn parse(&mut self, tokens: &mut impl Iterator<Item = i32>)
{
let num_kids = tokens.next().unwrap();
let num_meta =... | true |
14273eceea1ad2c6ee810c4f1ce8956a215d64aa | Rust | derekam/tag-simulator | /src/simulation.rs | UTF-8 | 6,548 | 3.203125 | 3 | [] | no_license | use crate::environment::Environment;
use crate::parameters::{TagParams};
use crate::tag_environment::TagEnvironment;
use dashmap::DashMap;
use crate::action::Action;
use crate::controls::Controls;
use iced::{Application, Settings, window};
use crate::agents::agent::Agent;
use std::collections::HashSet;
/// The main ta... | true |
2f21c986bfd1d5459c41b96c2883f449b1d2be71 | Rust | lazareviczoran/advent-of-code-2020 | /day-06/src/main.rs | UTF-8 | 2,012 | 3.65625 | 4 | [] | no_license | use std::collections::HashSet;
use std::fs::File;
use std::io::prelude::*;
fn main() {
let data = read("input.txt");
println!("part1 solution: {}", count_all_unique_yes_answers(&data));
println!("part2 solution: {}", count_unique_yes_answers_by_all(&data));
}
fn count_all_unique_yes_answers(data: &[Vec<S... | true |
133f3fd3381db53c511d388a689ee516d9bf984a | Rust | entropitor/cpl-window-manager | /assignment/src/fixed_window_manager.rs | UTF-8 | 587 | 2.734375 | 3 | [] | no_license | //! This module adds some missing methods to properly implement all WindowManagers
use cplwm_api::types::{Window, WindowWithInfo};
use cplwm_api::wm::WindowManager;
/// The RealWindowInfo allows wrappers to access the interesting WindowWithInfo (not just the tiled one)
pub trait RealWindowInfo: WindowManager {
///... | true |
29e103702281d7dba5a7029626b12fa02a086a04 | Rust | opensource-assist/fuschia | /src/sys/test_adapters/rust/src/main.rs | UTF-8 | 2,862 | 2.578125 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
mod rust_test_adapter;
use {
anyhow::{format_err, Context as _, Error},
fidl_fuchsia_test as ftest, fuchsia_async as fasync,
fuchsia_component... | true |
d87e9ec463a00286a097a3738c52d157ca5b661f | Rust | Patryk27/cr8r | /apps/controller/src/system/modules/attachment/actor.rs | UTF-8 | 2,028 | 2.703125 | 3 | [
"MIT"
] | permissive | use std::path::PathBuf;
use std::sync::atomic::Ordering;
use chrono::{DateTime, Utc};
use log::*;
use tokio::fs::{File, remove_file};
use tokio::stream::StreamExt;
use tokio::time::{delay_for, Duration};
use lib_core_channel::URx;
use lib_interop::models::{DAttachmentId, DAttachmentName};
use lib_interop::proto::mode... | true |
ca5f9b08097d6be397cc1049c4dcea34ba062429 | Rust | inda21plusplus/mathm-chess | /chess-engine/src/tests.rs | UTF-8 | 10,188 | 3.046875 | 3 | [] | no_license | use std::collections::HashSet;
use crate::*;
#[test]
fn arabic_parsing() {
for (input, output) in [
("a4a5", Move::from(((0, 4).into(), (0, 3).into()))),
("h5h1", ((7, 3).into(), (7, 7).into()).into()),
("a1h8", ((0, 7).into(), (7, 0).into()).into()),
("b5a7", ((1, 3).into(), (0, 1... | true |
3c0ecf018d7b15505df8e93aa72f5547ad635e54 | Rust | abusch/rtiow | /src/hitable/boxx.rs | UTF-8 | 2,145 | 2.734375 | 3 | [] | no_license | use std::sync::Arc;
use crate::aabb::Aabb;
use crate::hitable::{FlipNormals, HitRecord, Hitable, XYRect, XZRect, YZRect};
use crate::material::Material;
use crate::ray::Ray;
use crate::Vec3;
pub struct Boxx {
pmin: Vec3,
pmax: Vec3,
list_ptr: Vec<Arc<dyn Hitable>>,
}
impl Boxx {
pub fn new(p0: Vec3, ... | true |
94d4c31ff3da9825f6159573f3ecfdfc1d92a260 | Rust | erikjara/rut-lib | /examples/range.rs | UTF-8 | 324 | 3.234375 | 3 | [
"MIT"
] | permissive | use rut_lib::Rut;
fn main() {
let number = 24136773;
match Rut::from_number(number) {
Ok(rut) => {
println!("Number: {:#}", rut.number());
println!("DV: {:#}", rut.dv());
println!("RUT: {:#}", rut)
}
Err(error) => println!("Error: {:#}", error),
... | true |
364aed03d5089708574be73fafd57d6d80137a7c | Rust | noshi91/n91lib_rs | /src/algorithm/determinant.rs | UTF-8 | 1,386 | 3.203125 | 3 | [
"CC0-1.0"
] | permissive | /*
Description
T: 体
a: T 上の n × n 行列
a の行列式を計算する。
時間計算量: Θ(n^3) 回の演算と Θ(n) 回の除算
オーソドックスな掃き出し法。
*/
use crate::other::algebraic::{one, zero, Field};
pub fn determinant<T>(mut a: Vec<Vec<T>>) -> T
where
T: Field + Clone,
{
let n = a.len();
for a in &a {
assert_eq!(a.len(), n);
}
let mu... | true |
573ef9b2e886fef0f4683eb3db18cbb9fa08e27e | Rust | LeJane/rust | /v1/src/postgresql_db_contexts/equipments.rs | UTF-8 | 3,934 | 2.53125 | 3 | [] | no_license | use crate::models::equipments::Equipment;
use crate::schema::equipments;
use crate::{utils::binary_read_helper::*, BinaryDecode, BinaryEncode};
use crate::{
FrontDisplayMetaVersion, FrontDisplayMetaVersionRelation, MetadataInstance, MetadataTypeEnum,
TableIdEnum,
};
use anyhow::Result;
use diesel::prelude::*;
... | true |
2119ae5e289577ce9467819168bd073c0d1adc03 | Rust | netvipec/AoC2017 | /Rust/day24/src/main.rs | UTF-8 | 4,200 | 3.171875 | 3 | [] | no_license | use std::collections::HashMap;
use std::io::{self, BufRead};
type InputT = Vec<(usize, usize)>;
type OutputT = usize;
fn read_input() -> InputT {
let stdin = io::stdin();
let input: InputT = stdin
.lock()
.lines()
.map(|x| {
let line = x.unwrap();
let elements =... | true |
47b3e1dbd71d5efaccef803126b7bc2440730fe7 | Rust | dstaatz/kdtree-na | /benches/bench.rs | UTF-8 | 2,245 | 2.71875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![feature(test)]
extern crate kdtree_na;
extern crate nalgebra;
extern crate rand;
extern crate test;
use kdtree_na::norm::EuclideanNormSquared;
use kdtree_na::KdTree;
use nalgebra::{DVector, Vector3};
use test::Bencher;
fn rand_data_static() -> (Vector3<f64>, f64) {
(Vector3::new_random(), rand::random())
}
#[... | true |
07e53b5f85aab1250d0679a6955c0cc201426c4a | Rust | GaiaWorld/pi_lib | /hash/src/lib.rs | UTF-8 | 2,617 | 2.953125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! 本模块提供`XHashMap`、`XHashSet`两种容器,来替代标准库的HashMap和HashSet。
//! 意在鼓励外部库大多数时候都使用本模块提供的XHashMap、XHashSet来替代标准库或其它库的HashMap和HashSet。
//! 使用本模块的优势在于,库的编写者,在使用这两种容器时,不用关心使用哪种hash算法
//! 而由具体的应用程序关心,应用程序可以设置不同的feature,来确定自己需要哪种hash算法。
//!
//! 例如:
//! 一个名为`gui`的库,使用了本模块的XHashMap;
//!
//! 另一个库`gui_web`,是对`gui`的再次封装,意在编译为asm供web... | true |
a1d16944982e36f7001f041c0519e6bee07b7ea7 | Rust | seritools/rust | /src/tools/clippy/clippy_lints/src/returns.rs | UTF-8 | 9,788 | 2.890625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | use if_chain::if_chain;
use rustc_ast::ast;
use rustc_ast::visit::FnKind;
use rustc_errors::Applicability;
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Span;
use rustc_span::B... | true |
f65db069c084b4f14ac3b8aea903544b2ec19151 | Rust | GavinRay97/reaper-rs | /main/medium/src/reaper_pointer.rs | UTF-8 | 3,082 | 2.84375 | 3 | [
"MIT"
] | permissive | use super::{MediaItem, MediaItemTake, MediaTrack, ReaProject, TrackEnvelope};
use crate::{concat_reaper_strs, PcmSource, ReaperStr, ReaperStringArg};
use std::borrow::Cow;
use std::os::raw::c_void;
/// Validatable REAPER pointer.
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub enum ReaperPointer<'a> {
MediaTrack... | true |
00a1c1d7c95863ee33307775bc8c27225665b4c2 | Rust | ericdke/NatoPhone-Rust | /src/decode.rs | UTF-8 | 1,462 | 3.296875 | 3 | [] | no_license | use std::collections::HashMap;
pub fn translated(words: Vec<String>, yell: bool) -> String {
let st = translate(words).join("");
if yell { st.to_uppercase() } else { st }
}
fn translate(words: Vec<String>) -> Vec<String> {
let dic = get_map();
let mut bucket: Vec<String> = Vec::new();
for word in ... | true |
d30d530dd86afec040e11dbb690718e8aecebd6a | Rust | sum12/rustbook | /strings/string_ownsership.rs | UTF-8 | 317 | 3.546875 | 4 | [] | no_license | fn main() {
let s = String::from("get length of this string");
println!("{}", calc_len(&s));
let (x, s) = ret_tuple(s);
println!("length from tuple {}", x);
println!("{}", s);
}
fn calc_len(s: &String) -> usize {
s.len()
}
fn ret_tuple(x: String) -> (usize, String) {
(x.len(), x)
}
| true |
35c23187d42026bf72387b1c80a01c7a82155372 | Rust | colin353/rules_rust | /tools/rustdoc/rustdoc_test_writer.rs | UTF-8 | 6,234 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | //! A utility for writing scripts for use as test executables intended to match the
//! subcommands of Bazel build actions so `rustdoc --test`, which builds and tests
//! code in a single call, can be run as a test target in a hermetic manner.
use std::cmp::Reverse;
use std::collections::{BTreeMap, BTreeSet};
use std:... | true |
10648413b854c575bbf9978f02bf9de86ba80ba8 | Rust | GrayChrysTea/mtdalgos | /src/macros/errconvert.rs | UTF-8 | 2,120 | 3.40625 | 3 | [
"MIT"
] | permissive | //! This module contains macro definitions for handling [`Result`]s and
//! [`Options`].
/// Destructures an [`Option`] and sends the item contained within back out
/// if the [`Option`] destructures to [`Some(..)`], else a [`std::io::Error`]
/// is propagated from the function.
#[macro_export]
macro_rules! unwrapopti... | true |
414df50556c4c2dba797be85a47cecd9bfddcb0f | Rust | dbrgn/atat | /atat/src/client.rs | UTF-8 | 18,633 | 2.71875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use bbqueue::framed::FrameConsumer;
use embedded_hal_nb::{nb, serial};
use fugit::ExtU32;
use crate::error::{Error, Response};
use crate::helpers::LossyStr;
use crate::traits::{AtatClient, AtatCmd, AtatUrc};
use crate::Config;
#[derive(Debug, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
enum Clie... | true |
f77d8841c0cce0eee793808b4064175c40d4ee93 | Rust | PartyLich/tetrs | /cell_engine/src/menu/mod.rs | UTF-8 | 1,625 | 3.328125 | 3 | [] | no_license | use std::fmt;
/// A selectable item in a `Menu`
#[derive(Debug, PartialEq)]
pub struct MenuItem<T>
where
T: fmt::Debug + PartialEq + Clone,
{
pub label: &'static str,
pub event: T,
}
impl<T> MenuItem<T>
where
T: fmt::Debug + PartialEq + Clone,
{
pub fn new(label: &'static str, event: T) -> Self {
... | true |
f93eafb93d01cdc848bffd7e87c047b8f46d0fad | Rust | miso24/rust_brainfuck | /src/parser.rs | UTF-8 | 3,463 | 3.359375 | 3 | [] | no_license | use crate::lexer::Token;
use std::collections::HashMap;
use std::fmt;
#[derive(Debug, PartialEq)]
pub enum Instruction {
Add(u8),
Sub(u8),
AddPtr(u8),
SubPtr(u8),
Write,
Read,
JumpToLBracket(usize),
JumpToRBracket(usize),
}
#[derive(Debug)]
pub enum ParseError {
UnclosedBracket,
}
... | true |
fd87dc6b376b5432d0e264c558bc6c51252a8893 | Rust | m-kann0/atcoder-rust | /examples/tdpc_dice.rs | UTF-8 | 2,451 | 3.421875 | 3 | [] | no_license | use std::io::Read;
fn main() {
let mut buf = String::new();
std::io::stdin().read_to_string(&mut buf).unwrap();
let answer = solve(&buf);
println!("{}", answer);
}
fn solve(input: &str) -> String {
let mut iterator = input.split_whitespace();
let n: usize = iterator.next().unwrap().parse().... | true |
26bc7933b2d99ac29b84c06cff5a99ec32f362af | Rust | b-r-u/nori | /src/main.rs | UTF-8 | 11,647 | 2.671875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::fs::File;
use anyhow::Context;
use clap::{Arg, ArgGroup, App, AppSettings, SubCommand};
use geomatic::Point4326;
use serde::Serialize;
mod bounding_box;
mod compare;
mod density;
mod geojson_writer;
mod network;
mod polyline;
mod poi;
mod route;
mod routing_machine;
mod sampling;
use bounding_box::BoundingB... | true |
a0ad2b870879e1529fd046682701d6dc053bf7da | Rust | isgasho/telefork | /examples/yoyo_client_raw.rs | UTF-8 | 1,913 | 3.359375 | 3 | [] | no_license | use telefork::{telefork, telepad, wait_for_exit, TeleforkLocation};
use std::net::TcpStream;
use std::os::unix::io::FromRawFd;
fn main() {
let args: Vec<String> = std::env::args().collect();
let destination = args.get(1).expect("expected arg: address of teleserver");
println!("Hello, I'm a process that's... | true |
4ea3393ea22cf5a8fea6efc46905d4ca865c7d8f | Rust | tatakahashi35/atcoder | /abs/src/bin/abc049c.rs | UTF-8 | 819 | 2.953125 | 3 | [] | no_license | use proconio::input;
fn main() {
input!{
s: String,
}
let mut answer = true;
let l = s.len();
let mut i = 0;
while i < l {
if s[i..].to_string().starts_with(&"dreameraser") {
i += 11;
} else if s[i..].to_string().starts_with(&"dreamerase") {
i +... | true |
0d19f90484eecdc027559504b2be5ffa996d96d7 | Rust | svmk/fund-watch-bot | /src/market/market_data/model/actual_chart_period.rs | UTF-8 | 1,351 | 2.828125 | 3 | [] | no_license | use crate::{app::model::datetime::DateTime, market::market_data::model::chart_period::ChartPeriod};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ActualChartPeriod {
#[serde(rename = "period")]
period: Option<ChartPeriod>,
}
impl ActualChartPeriod {
pub fn new_uncached() -> ActualChartPeriod ... | true |
dbce77545c1ce2230e52b6431ddac22597da0015 | Rust | darshanparajuli/AdventOfCode2020 | /src/bin/day1.rs | UTF-8 | 880 | 3.09375 | 3 | [] | no_license | use aoc_2020::read_input;
fn main() {
let input: Vec<_> = read_input()
.iter()
.map(|e| e.parse::<u32>().unwrap())
.collect();
part1(&input);
part2(&input);
}
fn part1(input: &[u32]) {
let mut answer = 0;
'outer: for i in input {
for j in input.iter().filter(|e| *e... | true |
cfbde0d718d53a9c6d2251e8d010649d81bbec79 | Rust | shadow/shadow | /src/main/utility/synchronization/count_down_latch.rs | UTF-8 | 12,128 | 3.40625 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | use std::sync::{Arc, Condvar, Mutex};
/// A latch counter.
///
/// If a counter is cloned, it will inherit the counter's state for the current generation. For
/// example if a counter is cloned after it has already counted down, then the new counter will also
/// be treated as if it had already counted down in the cur... | true |
28666df7d43a7578b7bac1722959cd5232222940 | Rust | Josh7GAS/Oficina | /Rust/test/web_crawler/src/main.rs | UTF-8 | 1,749 | 3.09375 | 3 | [] | no_license | use html5ever::tokenizer::{
BufferQueue,
Tag,
TagKind,
TagToken,
Token,
TokenSink,
TokenSinkResult,
Tokenizer,
TokenizerOpts,
};
use std::borrow::Borrow;
use url::{ ParseError, Url};
#[derive(Default, Debug)]
struct LinkQueue{
links: Vec<String>,
}
impl TokenSink for &mut Lin... | true |
a0cdacc0595aee426e1edf768473c4e75c435dba | Rust | jblindsay/whitebox-tools | /whitebox-common/src/algorithms/delaunay_triangulation.rs | UTF-8 | 18,923 | 3.6875 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /*!
The following code has been modified from the original delaunator-rs project:
https://github.com/mourner/delaunator-rs
For a description of the data structure, including the halfedge connectivity, see:
https://mapbox.github.io/delaunator/
# Description
A very fast 2D [Delaunay Triangulation](https://en.wikiped... | true |
3a2c6344f90793b610cc37eec41071107b72ea91 | Rust | iCodeIN/edu-json-parser | /edu-json-parser/src/lib.rs | UTF-8 | 10,203 | 2.53125 | 3 | [] | no_license | #[macro_use]
extern crate compre_combinee;
extern crate combine;
mod errors;
mod details;
mod traits;
mod stop_watch;
use std::collections::{HashMap};
use combine::{parser, eof, satisfy, choice, attempt};
use combine::parser::range::{take_while1};
use combine::parser::char::*;
use combine::{Parser, many, optional, sk... | true |
650bf934fa78786cb7ce1f0594ecc24b64b5ae75 | Rust | jasbok/rxr | /src/dosbox_config.rs | UTF-8 | 3,918 | 3.1875 | 3 | [] | no_license | use std::collections::HashMap;
use std::error::Error;
use std::io::BufReader;
use std::fs::File;
use std::io::prelude::*;
use std::path::PathBuf;
use regex::Regex;
#[derive(Default, Deserialize, Debug, Clone, PartialEq)]
pub struct DosboxConfig {
pub autoexec: Vec<String>,
pub settings: HashMap<String, HashMa... | true |
38d74aee11840118cae1af177080609957e29f83 | Rust | kalleakerblom/AdventOfCode2019 | /src/day11.rs | UTF-8 | 4,209 | 3.296875 | 3 | [] | no_license | use super::int_code::Program;
use std::collections::HashMap;
struct Robot {
pos: (i32, i32),
dir: (i32, i32),
program: Program,
}
enum Turn {
Left,
Right,
}
#[derive(Clone, Copy)]
enum Color {
Black,
White,
}
impl Robot {
fn new(program: Program) -> Self {
Robot { dir: (0, 1), p... | true |
817fcf404a1ba5629e7cca0c791d8682595e5536 | Rust | Matthew-Maclean/stag | /src/rgb.rs | UTF-8 | 6,839 | 2.609375 | 3 | [
"MIT"
] | permissive | use image::RgbImage;
use rand::Rng;
use itertools::Itertools;
use utils::*;
use codec::Codec;
pub struct RgbCodec;
impl Codec for RgbCodec
{
type Input = RgbImage;
type Mode = RgbMode;
fn encode<R: Rng>(
source: &mut RgbImage,
payload: &[u8],
_mode: RgbMode,
mut rng: R)
... | true |
2c57a05c7cfa7e8a66b402bf9a350f94387afaab | Rust | kulicuu/Peregrine | /src/bin/VulkanoPeregrine/utils.rs | UTF-8 | 6,612 | 2.859375 | 3 | [] | no_license |
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer, ImmutableBuffer};
use vulkano::device::{Device, DeviceExtensions};
use std::sync::Arc;
use std::str::FromStr;
use std::io::prelude::*;
use std::path::Path;
pub fn process_str_ints(input : &str) -> Vec<u32> {
let start = String::from(input);
let mut l... | true |
ebfeabc1c2a26a2a8b8400c3c0d36c55dc042ec0 | Rust | ajruckman/libvirt-grpc-api | /src/thread_safe_virt_conn.rs | UTF-8 | 488 | 2.578125 | 3 | [] | no_license | use std::sync::{Mutex, MutexGuard};
use virt::connect::Connect;
pub struct ThreadSafeVirtConn {
conn: Mutex<Connect>,
}
impl ThreadSafeVirtConn {
pub fn new(uri: &str) -> ThreadSafeVirtConn {
ThreadSafeVirtConn {
conn: Mutex::new(Connect::open(uri).unwrap()),
}
}
pub fn lo... | true |
8bfbb60dd4fd86439ed6765abefe0d41f16615b8 | Rust | wasmbet/wasmbet-contract | /tests/integration.rs | UTF-8 | 4,752 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | //! This integration test tries to run and call the generated wasm.
//! It depends on a Wasm build being available, which you can create with `cargo wasm`.
//! Then running `cargo integration-test` will validate we can properly call into that generated Wasm.
//!
//! You can easily convert unit tests to integration test... | true |
ae8d1ed9c8e1fa1b1131b02ec283f19557f16712 | Rust | Emulator000/telegram-bot | /raw/src/requests/forward_message.rs | UTF-8 | 1,544 | 3.15625 | 3 | [
"MIT"
] | permissive | use std::ops::Not;
use requests::*;
use types::*;
/// Use this method to forward messages of any kind.
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
#[must_use = "requests do nothing unless sent"]
pub struct ForwardMessage {
chat_id: ChatRef,
from_chat_id: ChatRef,
#[serde(skip_serializing_if ... | true |
d5662113de65a5fc04153d5b15b61f9204d9a302 | Rust | ruza-net/eru | /src/components/general/main_layout.rs | UTF-8 | 9,164 | 2.53125 | 3 | [] | no_license | use crate::styles::container::PADDING;
use crate::components::{
opetope,
app::{ Error, GlobalMessage, Data },
pop_up::{ self, PopUp, Form },
general::Sidebar,
};
#[derive(Debug, Clone)]
pub enum Message {
UpdatedName(String),
UpdatedFirstWrap(String),
UpdatedSecondWrap(String),
Ex... | true |
3847def25254f011edbd3bfbf3743e8e9175100e | Rust | kohbis/leetcode | /algorithms/1403.minimum-subsequence-in-non-increasing-order/solution.rs | UTF-8 | 444 | 2.75 | 3 | [] | no_license | impl Solution {
pub fn min_subsequence(nums: Vec<i32>) -> Vec<i32> {
let mut sub = Vec::new();
let mut sub_sum = 0;
let mut sum = nums.iter().sum();
let mut nums = nums.clone();
nums.sort();
nums.reverse();
while sub_sum <= sum {
sub.push(nums[0]... | true |
d7677f017cdc09c25c96c240f8f7620f1a9cbb8d | Rust | xarvic/ui_system | /src/renderer/renderer.rs | UTF-8 | 8,167 | 2.671875 | 3 | [] | no_license | use glium::backend::{Facade, Context};
use glium::{Program, DrawParameters, Blend, Frame, Surface, ProgramCreationError};
use std::fs::{read_to_string, File};
use std::rc::Rc;
use crate::renderer::{load_texture, CommandBuffer, Builder};
use image::ImageFormat;
use glium::texture::{texture2d::Texture2d};
use std::path::... | true |
8f6bbac0115577873a87248b77bdf9f6c60bb3b0 | Rust | mmmpa/snippets | /Rust/file.rs | UTF-8 | 1,581 | 3.125 | 3 | [] | no_license | #[test]
fn test_simple_file() {
let path = "./tmp/test_simple_file.txt";
fs::write(path, "a\nb\nc");
// Rust raw fs call syscall each instruction.
// Should use BufReader or BufWriter due to its bad performance.
let mut f = OpenOptions::new()
.read(true)
.write(true)
.open(path)... | true |
21f386139f26a1ccee2a78f643097e025f952b34 | Rust | heavypackets/skr | /src/types.rs | UTF-8 | 1,007 | 2.6875 | 3 | [] | no_license | use std::collections::{HashMap, HashSet};
pub type TypeName = String;
pub type TypeAttributeKey = String;
pub type TypeAtrributeValue = String;
pub type TypeAttributes = HashMap<TypeAttributeKey, TypeAtrributeValue>;
pub type TypeCollection = HashMap<TypeName, Type>;
pub type Types = HashSet<TypeName>;
pub type EnumV... | true |
3c9c044676b3f94baaca9039fff142e95340db79 | Rust | urielvan/leetcode-rust | /src/p0001_two_sum.rs | UTF-8 | 664 | 3.5625 | 4 | [
"MIT"
] | permissive | use std::collections::HashMap;
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let length = nums.len();
let mut rest: i32;
let mut hash: HashMap<&i32, i32> = HashMap::with_capacity(length);
for i in 0..length {
rest = target - nums[i];
if hash.contains_key(&rest) {
... | true |
79b450bcd2e8fe03231977316db7cb9c5415b7f2 | Rust | ritsz/rust-programming | /clone_trait.rs | UTF-8 | 2,030 | 4.21875 | 4 | [] | no_license |
use std::fmt;
/* Copy can be derived only by data that can implement implicit copy.
Can't have String, we used &str here.
That results in another issue then. Since str is a reference and we don't own it,
we need to tell how long the reference needs to stay around.
We use 'a to specify that reference stay... | true |
39e9487d828b748c4c77205565fb44c4eea9157a | Rust | cuviper/debug-helper | /examples/fake_struct.rs | UTF-8 | 535 | 3.109375 | 3 | [
"MIT"
] | permissive | #[macro_use(impl_debug_for_struct)]
extern crate debug_helper;
use std::fmt::{self, Debug, Formatter};
pub struct A(pub u8, pub i16, pub f64);
impl Debug for A {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
impl_debug_for_struct!(A, f, self, let .f1 = self.0, let .f2 = self.1, let .f3... | true |
95f31a1cf5c61a776589cc856bea1b3b39af69b8 | Rust | kosslab-kr/rust | /src/test/compile-fail/issue-21221-1.rs | UTF-8 | 2,510 | 3.203125 | 3 | [
"MIT",
"Apache-2.0",
"NCSA",
"ISC",
"LicenseRef-scancode-public-domain",
"BSD-3-Clause",
"BSD-2-Clause",
"Unlicense",
"LicenseRef-scancode-other-permissive"
] | permissive | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... | true |
6b7c87659543277166b010d78dd9671ee9d8ae44 | Rust | tauri-apps/tauri | /core/tauri-utils/src/resources.rs | UTF-8 | 4,188 | 2.9375 | 3 | [
"Apache-2.0",
"CC0-1.0",
"MIT",
"CC-BY-NC-ND-4.0"
] | permissive | // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use std::path::{Component, Path, PathBuf};
/// Given a path (absolute or relative) to a resource file, returns the
/// relative path from the bundle resources directory where th... | true |
810c14193d78ada07b84a94b6a842dbbf5e56e03 | Rust | korrat/fw | /src/projectile/mod.rs | UTF-8 | 3,101 | 2.703125 | 3 | [
"WTFPL"
] | permissive | use crate::config::Config;
use crate::errors::AppError;
use regex::Regex;
use slog::debug;
use slog::Logger;
use std::borrow::ToOwned;
use std::fs;
use std::io;
use std::io::Write;
use std::path::PathBuf;
pub fn projectile(maybe_config: Result<Config, AppError>, logger: &Logger) -> Result<(), AppError> {
let config:... | true |
e6489d045c451693057846c4c4ae0f75b06614ad | Rust | thepowersgang/equation-editor | /src/expression.rs | UTF-8 | 9,109 | 3.59375 | 4 | [] | no_license |
//!
//! Expression type
//!
#[derive(Debug,PartialEq,Eq,Copy,Clone)]
pub enum Op
{
Equality,
AddSub, // Note: Subtract is handled with `negated`
MulDiv,
ExpRoot, // NOTE: Root doesn't actually exist
}
#[derive(Debug,Clone,PartialEq)]
pub enum Expression
{
/// Negate the inner value
Negative(Box<Expression>),
/... | true |
5a2e48d557896ffd19340ba3d558d1ee61bb36a2 | Rust | BarePotato/gooey | /core/src/styles/font_size.rs | UTF-8 | 748 | 3.28125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use figures::Figure;
use stylecs::StyleComponent;
use crate::Scaled;
/// The font size for drawing text.
#[derive(Debug, Copy, Clone)]
pub struct FontSize(pub Figure<f32, Scaled>);
impl Default for FontSize {
fn default() -> Self {
Self::new(14.)
}
}
impl FontSize {
/// Creates a new `FontSize` ... | true |
4d5ba681bff5e2295afc920658f10adac1038ef3 | Rust | CSML-by-Clevy/csml-engine | /csml_interpreter/src/data/error_info.rs | UTF-8 | 3,186 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | use crate::data::{
literal::{create_error_info, Literal},
position::Position,
};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
////////////////////////////////////////////////////////////////////////////////
// DATA STRUCTURE
//////////////////////////////////////////////////////////////... | true |
fdd1997599e293c4c2cbeccc5ac068e55d5356f3 | Rust | teromene/activityrust | /src/entities/link.rs | UTF-8 | 3,938 | 2.65625 | 3 | [] | no_license | use crate::content::*;
use crate::entities::entity::{
ActivityStreamEntity, ActivityStreamEntityType, BoxedActivityStreamEntity,
};
use crate::traits::properties::*;
use crate::MaybeOptional;
use serde::{Deserialize, Serialize};
use url::Url;
impl ActivityStreamLinkProperties for ActivityStreamLink {
fn get_id... | true |
1d46c6bf9541d17c0d24d80bdd475b714c5e116d | Rust | xujihui1985/learningrust | /adder/src/lib.rs | UTF-8 | 685 | 3.671875 | 4 | [] | no_license | #[derive(Debug)]
pub struct Rectangle{
length: u32,
width: u32,
}
impl Rectangle {
pub fn can_hold(&self, other: &Rectangle) -> bool {
self.length > other.length && self.width > other.width
}
pub fn panic() {
panic!("panic");
}
}
#[cfg(test)]
mod tests {
use super::*;
... | true |
1c2ab600812b849caa9c88c61ddaabf0c8d48808 | Rust | KappaDistributive/aoc2015rust | /day10/src/main.rs | UTF-8 | 663 | 3.328125 | 3 | [] | no_license |
//const INPUT: Vec<u32> = [1,1,1,3,2,2,2,1,1,3].to_vec();
fn look_and_say(input: &Vec<usize>) -> Vec<usize>{
let mut result: Vec<usize> = Vec::new();
let mut i: usize = 0;
while i < input.len() {
let digit = input[i];
let mut counter: usize = 0;
while i < input.len() && input[... | true |
74b15a21b0d61ba4be805fa5b2b54e7a06e7f30d | Rust | nghenglim/sqlink | /sqlink/src/postgres/op.rs | UTF-8 | 1,017 | 2.578125 | 3 | [
"MIT"
] | permissive | use crate::postgres::query_field::{ParameterValueAsRef};
use crate::postgres::query_token::{format_query, TmpQueryTokens};
pub fn eq<S: Into<String>>(field: S, arg: ParameterValueAsRef) -> (TmpQueryTokens, Vec<ParameterValueAsRef>) {
format_query(format!("{} = {{}}", field.into()), vec![arg])
}
pub fn lt<S: Into<S... | true |
e68c172731503e411982046e15ed0545ef409a07 | Rust | Nugine/nuclear | /src/router.rs | UTF-8 | 9,247 | 2.90625 | 3 | [
"MIT"
] | permissive | use crate::error::StatusError;
use crate::http::Method;
use crate::internal_prelude::*;
use std::ops::{Range, RangeFrom};
use std::str::FromStr;
use smallvec::SmallVec;
#[derive(Default)]
pub struct SimpleRouter {
router: Router,
effects: Vec<Box<dyn Handler>>,
default: Option<Box<dyn Handler>>,
}
pub s... | true |
17a830df99974e06d59ceb4357b01904a2a58800 | Rust | filipeamoreira/playground | /languages/rust/playground.rs | UTF-8 | 384 | 3.40625 | 3 | [] | no_license | struct Number {
odd: bool,
value: i32
}
trait Signed {
fn is_negative(self) -> bool;
}
impl Signed for Number {
fn is_negative(self) -> bool {
self.value < 0
}
}
fn main() {
let odd = Number { odd: false, value: -40 };
let even = Number { odd: true, value: 0 };
println!("{}"... | true |
0c73e7540d93d1d6838f99d85b4f562a40724122 | Rust | radhakrishnang/goko | /serve_goko/src/errors.rs | UTF-8 | 4,490 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use std::error::Error;
use std::fmt;
use goko::errors::GokoError;
use tokio::sync::oneshot;
pub enum InternalServiceError {
Other(GokoError),
FailedSend,
FailedRecv,
FailedRespSend,
DoubleRead,
ClientDropped,
}
impl From<oneshot::error::RecvError> for InternalServiceError {
fn from(_e: one... | true |
eea57ab70b6af15e1d1db11a3838545eaeafd746 | Rust | aptend/leetcode-rua | /Rust/src/n1201_ugly_number_iii.rs | UTF-8 | 1,002 | 3.453125 | 3 | [] | no_license | pub fn nth_ugly_number(n: i32, a: i32, b: i32, c: i32) -> i32 {
fn gcd(mut x: i64, mut y: i64) -> i64 {
while y > 0 {
let tmp = x;
x = y;
y = tmp % y;
}
x
}
let (n, a, b, c) = (i64::from(n), i64::from(a), i64::from(b), i64::from(c));
let ab = ... | true |
adb83166f42f0b1fe1a51953a4b07c40b6ab68bb | Rust | plorefice/tracy | /tracy/src/rendering/pattern.rs | UTF-8 | 6,157 | 3.28125 | 3 | [] | no_license | use crate::math::{Matrix, Point3};
use super::Color;
/// A nestable, colored pattern.
#[cfg_attr(
feature = "serde-support",
derive(serde::Serialize, serde::Deserialize)
)]
#[derive(Debug, Clone, PartialEq)]
pub struct Pattern {
kind: PatternKind,
#[cfg_attr(feature = "serde-support", serde(default))]... | true |
e4ed91b9d24bf1a2e0a57f8f9205b93212ad148a | Rust | StoneDot/regtail | /tests/utils/mod.rs | UTF-8 | 5,529 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright 2019 StoneDot (Hiroaki Goto)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law o... | true |
d77490212377f1d42bb687825efebcf208017496 | Rust | gnoliyil/fuchsia | /src/testing/sl4f/src/hwinfo/types.rs | UTF-8 | 3,439 | 2.5625 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use fidl_fuchsia_hwinfo::{BoardInfo, DeviceInfo, ProductInfo};
use serde::Serialize;
#[derive(Clone, Debug, Serialize)]
pub struct SerializableDeviceInfo ... | true |
5ee0f6e1a6eafe053bdefd9d0241c9079129b908 | Rust | mrsekut/PracticeProgrammingLanguage | /Rust/src/compro.rs | UTF-8 | 293 | 3.359375 | 3 | [] | no_license | use std::io;
fn main() {
let mut guess = String::new();
io::stdin()
.read_line(&mut guess)
.expect("failed to read line"); // Errのときこの行が実行
let guess: u32 = guess.trim().parse().expect("please type a number")
print!("number: {:?}", guess);
}
| true |
903a5add5dc4dd886944805deb31dc69c7f9f192 | Rust | WangZehuiGit/rust-data-structrue | /src/bin_tree/height.rs | UTF-8 | 3,029 | 3 | 3 | [
"MIT"
] | permissive | use super::node::{HeightNode, Node};
use super::BinNode;
use super::InsertErr;
use super::Ptr;
use std::cmp::max;
use std::ptr::NonNull;
pub trait UpdateHeight<T>: HeightNode<T> {
fn stature(ptr: Ptr<Self>) -> usize {
if let Some(node) = ptr {
return unsafe { node.as_ref().height() };... | true |
468155f1bcc797a407b65bb11cd7d41a65c2664a | Rust | PushkarDureja/FizzBuzz | /fizz-buzz/rust.rs | UTF-8 | 281 | 2.9375 | 3 | [
"Unlicense"
] | permissive | use std::borrow::Cow;
fn main() {
for i in 1..100 {
println!("{}", match (i % 3, i % 5) {
(0, 0) => "FizzBuzz".into(),
(0, _) => "Fizz".into(),
(_, 0) => "Buzz".into(),
_ => Cow::from(i.to_string()),
});
}
}
| true |
53029769dbb6ee6ce2b8d22bca4d97e7b38398ca | Rust | afprusin/leetcode-rust | /src/bin/350_intersection_of_two_arrays_two.rs | UTF-8 | 878 | 3.25 | 3 | [] | no_license | use std::collections::{HashMap};
pub struct Solution {}
impl Solution {
pub fn intersect(nums1: Vec<i32>, nums2: Vec<i32>) -> Vec<i32> {
let mut exists: HashMap<i32, i32> = nums1.iter().fold(HashMap::new(), |mut acc, &c| {
*acc.entry(c).or_insert(0) += 1;
acc
});
le... | true |
d83190551b9c6fa22140c5aa6f9c496b014bb192 | Rust | eqlabs/pathfinder | /crates/storage/src/schema/revision_0032.rs | UTF-8 | 10,644 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use anyhow::Context;
use rusqlite::{params, Statement, Transaction};
/// Serialized to sqlite with full 32 bytes.
#[derive(Copy, Clone, serde::Deserialize)]
pub struct Felt(stark_hash::Felt);
/// Same as [Felt] but with leading zeros stripped when writing to sqlite.
#[derive(Copy, Clone, serde::Deserialize)]
pub stru... | true |
fa1a3c13eff9e8ca248b6037845b92324ff83706 | Rust | dhardy/rust-mersenne-twister | /benches/benchmarks.rs | UTF-8 | 3,157 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #![feature(test)]
extern crate test;
extern crate rand;
extern crate mersenne_twister;
mod mt19937 {
use rand::Rng;
use mersenne_twister::MT19937;
#[bench]
fn benchmark_seeding(b: &mut ::test::Bencher) {
b.iter(|| MT19937::new_unseeded());
}
#[bench]
fn benchmark_fill_next_state... | true |
a462467359a0ca5f3e7a155bebeb54103b10dc73 | Rust | Patryk-Kumor/University | /Rust/Projekt - aplikacja okienkowa/address-book/src/db.rs | UTF-8 | 2,293 | 2.90625 | 3 | [] | no_license | extern crate rustbreak;
extern crate failure;
use rustbreak::FileDatabase;
use rustbreak::deser::Ron;
use std::collections::HashMap;
#[derive(Eq, PartialEq, Debug, Serialize, Deserialize, Clone)]
pub struct Person {
pub name: String,
pub surname: String,
pub country: String,
pub city: String,
pub ... | true |
39aec71c3cba3e5f856b07a4c66c51e6302544d7 | Rust | faern/rips-old | /src/icmp/icmp_tx.rs | UTF-8 | 3,625 | 2.8125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use {Tx, Payload, CustomPayload, TxResult};
use ipv4::{Ipv4Fields, IpNextHeaderProtocols};
use pnet::packet::MutablePacket;
use pnet::packet::icmp::{IcmpCode, IcmpType, MutableIcmpPacket, checksum, IcmpTypes};
use pnet::packet::icmp::echo_request::{IcmpCodes, MutableEchoRequestPacket};
pub struct IcmpFields {
pub... | true |
1c7a69e36851414d15f08c10bf91f35f2662084d | Rust | naomijub/Observable-btree | /src/model.rs | UTF-8 | 7,170 | 3.5 | 4 | [
"MIT"
] | permissive | use std::{
collections::{BTreeMap, HashMap},
convert::{TryFrom, TryInto},
};
pub enum Operation {
Add,
Replace,
// ...
}
/// Available types to use as `BTree` values.
#[derive(Debug, Clone, PartialEq)]
pub enum Types {
Char(char),
Integer(isize),
UInteger(usize),
String(String),
... | true |
91e2fec35e687ee8c956343f8914ed884a2aef95 | Rust | guoonho/fftactics-arithmeticks-calculator | /src/main.rs | UTF-8 | 250 | 2.53125 | 3 | [] | no_license | use structopt::StructOpt;
mod arithmeticks;
#[derive(StructOpt)]
struct Cli {
state: String
}
fn main() {
let _args = Cli::from_args();
arithmeticks::validate(&_args.state);
println!("{}", arithmeticks::calculate(&_args.state));
}
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.