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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
50fc081767bb785addac73b19b062f19ac5b7002 | Rust | scarvalhojr/adventofcode2018 | /day04/tests/day04.rs | UTF-8 | 1,201 | 2.84375 | 3 | [] | no_license | use day04::{part1, part2, process_events, Event};
fn parse_input(input: &str) -> Vec<Event> {
input.lines().map(|s| s.trim().parse().unwrap()).collect()
}
#[test]
fn example() {
let input = "[1518-11-01 00:00] Guard #10 begins shift
[1518-11-01 00:05] falls asleep
[1518-11-01... | true |
5344a1ad3a7b58ef83fb58e4d3668fa21752c008 | Rust | z3t0/rust-screeps-api | /src/endpoints/login.rs | UTF-8 | 1,902 | 3.40625 | 3 | [
"MIT"
] | permissive | //! Interpreting login responses.
use EndpointResult;
use data;
use error::{Result, ApiError};
use std::borrow::Cow;
/// Login details
#[derive(Serialize, Debug, Clone)]
pub struct Details<'a> {
/// The email or username to log in with (either works)
pub email: Cow<'a, str>,
/// The password to log in wit... | true |
343a88796201207946504e075753c9c3b32af344 | Rust | jonathanlb/normal | /src/id_pairs_model.rs | UTF-8 | 8,081 | 3.140625 | 3 | [
"Apache-2.0"
] | permissive | use crate::{new_search_iterator, NormalError};
use sqlite::Connection;
/// Structure for maintaining pairs in a DB table.
pub struct IdPairs<'a> {
table_name: &'a str,
left_column_name: &'a str,
right_column_name: &'a str,
conn: Connection,
}
impl<'a> IdPairs<'a> {
pub fn new<'b>(
file_nam... | true |
a1b889aea04dcbd8faaaf38c56b828cdf7ebd31d | Rust | ilaborie/grass | /src/parse/style.rs | UTF-8 | 11,865 | 2.9375 | 3 | [
"MIT"
] | permissive | use codemap::Spanned;
use crate::{
error::SassResult,
interner::InternedString,
style::Style,
utils::{is_name, is_name_start},
value::Value,
Token,
};
use super::common::SelectorOrStyle;
use super::Parser;
impl<'a, 'b> Parser<'a, 'b> {
fn parse_style_value_when_no_space_after_semicolon(&... | true |
5b5729d02e89be04cc6e98b30f26ba5d4479a573 | Rust | jeffreylyg/RustByExample | /01. hello_world/src/main.rs | UTF-8 | 4,820 | 3.9375 | 4 | [] | no_license | use std::fmt;
fn main() {
formatted_print(); //1.2
formatted_print_debug(); //1.2.1
formatted_print_display(); //1.2.2
formatted_print_display_list(); //1.2.2.1
formatted_print_formatting(); //1.2.3
}
fn formatted_print() {
// In general, the `{}` will be automatical... | true |
a49eeb120f390dcf40723d13122f2657efc9bacb | Rust | imdaveho/tuitty-core | /src/terminal/posix.rs | UTF-8 | 5,482 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::io::{ Result, Error, ErrorKind };
use libc::termios as Termios;
use crate::actions::ansi::*;
use crate::common::enums::{ Clear, Style, Color };
pub struct Term { mode: Termios }
impl Term {
pub fn new() -> Result<Self> {
Ok(Self { mode: output::get_mode()? })
}
// CURSOR FUNCTIONS
p... | true |
2f4a078ebc77313d7cccbfd0c7a9a70c8c9e7095 | Rust | steveklabnik/rustboy | /src/disasm.rs | UTF-8 | 6,369 | 2.9375 | 3 | [
"BSD-3-Clause"
] | permissive | use cpu::{Addr8, Addr16, Cond, Decoder};
use cpu;
use mem;
pub struct Disasm<'a, M:'a> {
pub mem: &'a mut M,
pub pc: u16,
}
fn addr16_to_str(addr: Addr16) -> String {
match addr {
cpu::Imm16(val) => format!("${:04X}", val),
cpu::Ind16(addr) => format!("(${:04X})", addr),
cpu::Reg16Dir(r) => f... | true |
be00d3ba7e5f720a2537a1e4a3352a5cbd984b33 | Rust | m-kann0/atcoder-rust | /examples/abc140_c.rs | UTF-8 | 1,001 | 3.5625 | 4 | [] | no_license | use std::io::Read;
use std::cmp::min;
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(... | true |
98bd17c75abbb9a2c32cc95c2025cf260c478ca3 | Rust | sbnair/typestate-post | /typestate-rust/src/repair_order/typestate.rs | UTF-8 | 4,010 | 2.9375 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use super::{calculate_steps, find_idle_technician, Customer, Employee};
pub fn process(order: RepairOrder<New>) {
// assert_eq!(order.state, State::New);
let valid = match order.validate() {
Ok(valid) => valid,
Err(_) => {
return;
}
... | true |
804f95ca7b5c850fda9c0b2332a3ca9e2c039c66 | Rust | railwayhistory/railsite | /src/html/i18n/line.rs | UTF-8 | 25,371 | 2.78125 | 3 | [] | no_license | //! Translations for line document pages.
use raildata::document::OrganizationLink;
use raildata::document::line::{
Category, Concession, DeVzg, Electrified, Gauge, Goods, Passenger, Status
};
use raildata::types::{CountryCode, EventDate, List, LocalText, Marked, Set};
use crate::i18n::Lang::*;
use crate::site::Si... | true |
c0f6b479b5e0f1de7368d9d74655cb3227f8adc5 | Rust | Wdiviner/geektime-rust | /15_smart_pointers/src/mystring.rs | UTF-8 | 4,719 | 3.515625 | 4 | [
"Apache-2.0"
] | permissive | use std::{fmt, ops::Deref, str};
const MINI_STRING_MAX_LEN: usize = 30;
// MyString 里,String 有 3 个 word,供 24 字节,所以它以 8 字节对齐
// 所以 enum 的 tag + padding 最少 8 字节,整个结构占 32 字节。
// MiniString 可以最多有 30 字节(再加上 1 字节长度和 1字节 tag),就是 32 字节.
struct MiniString {
len: u8,
data: [u8; MINI_STRING_MAX_LEN],
}
impl MiniString ... | true |
646a6cc135e16a862887cac163a4c6340a2d0a8a | Rust | rustkel/date | /src/date.rs | UTF-8 | 6,659 | 3.6875 | 4 | [
"MIT"
] | permissive | ///Date utils
///Mostly for day counting between dates
/// There are many ways to count dates; here I have chosen:
/// - Gregorian date from 1582 AD onwards
/// - Julian date before that (Proleptic Julian Calendar)
/// - No year 0
/// It is more interesting from a computational point of view!
use std::fmt::{Display, ... | true |
49ff257161e067eb8b7ebcd0b4b5fb3863c9938c | Rust | jacobguenther/advent_of_code_2015 | /src/common/grid.rs | UTF-8 | 2,296 | 2.890625 | 3 | [
"MIT"
] | permissive | // File: common/grid.rs
// Author: Jacob Guenther
// Date: December 2020
/*
Copyright 2020 Jacob Guenther
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without li... | true |
a8543eab33923cfe4dd181319bfef1b76971c95f | Rust | TriMill/complexpr-old | /src/ops.rs | UTF-8 | 2,218 | 3.515625 | 4 | [] | no_license | use crate::Value;
use crate::function::{EvalError, EvalTrace};
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
pub enum BinaryOp {
Add, Sub, Mul, Div, Mod, Frac, Power,
Greater, Less, GreaterEqual, LessEqual, Equal, NotEqual
}
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
pub enum UnaryOp {
Neg
}
impl Binary... | true |
a4b1a9bfaedd4489ec5245bf7284a9a078650da7 | Rust | NhoLiemDinh/yew-dev-viewer | /src/devices.rs | UTF-8 | 4,281 | 3.078125 | 3 | [] | no_license | use crate::device::Device;
use crate::device_modal::DeviceModal;
use failure::Error;
use yew::format::{Json, Nothing};
use yew::services::fetch::{FetchService, FetchTask, Request, Response};
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender};
pub struct Devices {
devices: Vec<Device>,
fe... | true |
1fb632e01197ba0e1f6820cf9fd3b2bf1a150c87 | Rust | Aidiakapi/advent_of_code_2019 | /src/day12.rs | UTF-8 | 4,882 | 3.015625 | 3 | [
"Unlicense"
] | permissive | module!(pt1: parse, pt2: parse);
use crate::HashSet;
use num::{Integer, Signed};
use std::convert::Into;
type Vec3 = crate::vec3::Vec3i;
#[derive(Debug, Clone, PartialEq, Eq)]
struct CelestialBody {
position: Vec3,
velocity: Vec3,
}
impl CelestialBody {
fn potential_energy(&self) -> i32 {... | true |
8f7750fdc6ee5f51ae9e67ee26d1011d9ad08a86 | Rust | jgarte/mum | /mum/src/state/user.rs | UTF-8 | 6,201 | 2.515625 | 3 | [
"MIT"
] | permissive | use mumble_protocol::control::msgs;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct User {
channel: u32,
comment: Option<String>,
hash: Option<String>,
name: String,
priority_speaker: bool,
recording: bool,
suppress: bool, // by me
self_... | true |
27c46c4e34e31712f1cb2355126c3dcdd975cfe1 | Rust | shigedangao/maomao | /src/kube/workload/container/pod/container.rs | UTF-8 | 3,586 | 2.546875 | 3 | [] | no_license | use std::convert::{Into, From};
use std::collections::BTreeMap;
use k8s_openapi::api::core::v1::{
Container,
VolumeMount,
ResourceRequirements,
Probe
};
use k8s_openapi::apimachinery::pkg::api::resource::Quantity;
use crate::lib::parser::workload::{
Container as ParserContainer,
resource::Resour... | true |
de7fe216d745b8cdf69b2418bddb7366465a5e6f | Rust | royswale/leetcode | /src/bin/shan-chu-lian-biao-de-jie-dian-lcof.rs | UTF-8 | 1,025 | 3.265625 | 3 | [
"MIT"
] | permissive | fn main() {}
struct Solution;
// Definition for singly-linked list.
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>,
}
impl ListNode {
#[inline]
fn new(val: i32) -> Self {
ListNode { next: None, val }
}
}
impl Solution {
pub ... | true |
e4cec0bcd4d05a1a6fea042895178747be0723b6 | Rust | SHIINASAMA/rust_study | /own/src/main.rs | UTF-8 | 1,339 | 4.125 | 4 | [
"MIT"
] | permissive | fn main() {
let x:i32 = 1;
{
let y:i32 = 2;
println!("x = {}",x);
println!("y = {}",y);
}
//编译的时候数据类型和大小是固定的,就分配在栈上
//编译的时候数据类型和大小不是固定的,就分配在堆上
{
//此时x分配在堆上
//let mut x = String::from("Hello");
//x.push_str(" World");
let x = String::from("... | true |
fd5148d2a44cd647e4f3db3dc8f162f4f5dcecb3 | Rust | YoEight/eventstore-rs | /src/internal/commands.rs | UTF-8 | 57,203 | 2.890625 | 3 | [
"MIT"
] | permissive | //! Commands this client supports.
use std::collections::HashMap;
use std::ops::Deref;
use futures::channel::mpsc::{self, Sender};
use futures::stream::TryStreamExt;
use futures::Stream;
use protobuf::Chars;
use serde::ser::SerializeSeq;
use crate::internal::messaging::Msg;
use crate::internal::operations;
use crate:... | true |
18cd67a9b81deb96eae9edd2f759d697ff5da19a | Rust | tempbottle/os_pipe.rs | /src/windows.rs | UTF-8 | 3,303 | 2.640625 | 3 | [
"MIT"
] | permissive | extern crate winapi;
use std::fs::File;
use std::io;
use std::os::windows::prelude::*;
use std::process::Stdio;
use std::ptr;
use self::winapi::shared::minwindef::DWORD;
use self::winapi::shared::ntdef::{HANDLE, PHANDLE};
use self::winapi::um::{handleapi, namedpipeapi, processenv, winbase};
use PipeReader;
use PipeW... | true |
6fe4254ad12cae5e44bfc8e8c6e0bbc0da2939aa | Rust | RainbowCookie32/imguify | /src/ui/windows/playlist_window.rs | UTF-8 | 4,425 | 2.75 | 3 | [
"MIT"
] | permissive | use std::sync::Arc;
use imgui::*;
use crate::ui::AppState;
use crate::spotify::PlaylistData;
pub struct PlaylistWindow {
playlist: Arc<PlaylistData>
}
impl PlaylistWindow {
pub fn init(playlist: Arc<PlaylistData>) -> PlaylistWindow {
PlaylistWindow {
playlist
}
}
pub fn ... | true |
456c827db9bc39708bee45bfd7f69ad1090b13c9 | Rust | fridge-dev/lost-cities-game | /src/crates/storage/src/local_disk_storage/sqlite_integration.rs | UTF-8 | 4,474 | 3.09375 | 3 | [] | no_license | use rusqlite::{NO_PARAMS, Connection, OpenFlags, Row, ToSql};
use std::path::Path;
use crate::local_disk_storage::sqlite_tables::{SqlGameSummary, SqlGameData};
type SqliteResult<T> = Result<T, rusqlite::Error>;
/// Probably an unnecessary abstraction layer, but it helps me keep track of
/// all of the ways in which I... | true |
2494ffb8e64e468ffdf64e822124536ebd475938 | Rust | mnts26/aws-sdk-rust | /sdk/smithy-xml/src/decode.rs | UTF-8 | 17,662 | 3.203125 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use crate::unescape::unescape;
use std::borrow::Cow;
use std::convert::TryFrom;
use thiserror::Error;
use xmlparser::{ElementEnd, Token, Tokenizer};
pub type Depth = usize;
// in general, these errors... | true |
5fcac1f7c570e84a031990d08d796a13839042a2 | Rust | IThawk/rust-project | /rust-master/src/test/ui/enum/enum-size-variance.rs | UTF-8 | 630 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
#![warn(variant_size_differences)]
#![allow(dead_code)]
// Note that the following test works because all fields of the enum variants are of the same size.
// If this test is modified and the reordering logic in librustc/ty/layout.rs kicks in, it fails.
enum Enum1 { }
enum Enum2 { A, B, C }
enum Enum3 ... | true |
7f1881c787a6f852a503128ea1cdd91af2079754 | Rust | ED-NEWP/edsm | /src/lib.rs | UTF-8 | 1,173 | 2.96875 | 3 | [] | no_license | use std::fs::File;
mod serde_utils;
/// Faction information and state tracking
///
/// A populated system contains many factions, including it's primary faction which has the largest
/// influence. All faction's influence together add up to 1.0, meaning that a single faction
/// gaining influence means that others mu... | true |
e78f850e229b152dd1c6ad4745dabb8662d66816 | Rust | jankes/AdventOfCode | /2015/3/src/main.rs | UTF-8 | 2,658 | 2.9375 | 3 | [] | no_license | use std::collections::HashSet;
use std::error::Error;
use std::fs::OpenOptions;
use std::io::Read;
use std::path::Path;
fn main() {
let path = "C:\\Users\\jankes\\Documents\\AdventOfCode\\2015\\3\\input.txt";
let directions;
match get_directions(path) {
Err(e) => {
println!("failed to get directi... | true |
7beef77dbef3a472fae2e176eae1331a145a26c1 | Rust | naokiri/sandbox | /src/main.rs | UTF-8 | 332 | 2.609375 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate stdweb;
fn main() {
stdweb::initialize();
let message = "こんにちは 世界";
// Write javascript inside Rust code!?
js! {
// @{var_name} to use Rust variable in the js! macro
alert ( @{message} );
console.log( @{message} );
}
stdweb::event_loop();
}
| true |
445540a5e980842ee15d541da003026dad057708 | Rust | hacsoc/rust-cas | /src/cas.rs | UTF-8 | 7,131 | 2.78125 | 3 | [
"MIT"
] | permissive | extern crate url;
extern crate hyper;
extern crate xml;
use self::url::{Url, ParseError};
use self::hyper::server::response::Response;
use self::hyper::server::request::Request;
use self::hyper::status::StatusCode;
use self::hyper::header::Location;
use self::hyper::Client;
use self::hyper::error::Error as HyperError;... | true |
0acd012ec3c80d6c18f1703dbf0a6b1b72f808df | Rust | graydon/pergola | /src/lib.rs | UTF-8 | 4,386 | 3.09375 | 3 | [] | no_license | // Copyright 2020 Graydon Hoare <graydon@pobox.com>
// Licensed under the MIT and Apache-2.0 licenses.
/*!
This is a small crate that provides a generic unital-join-semilattice type
(hereafter: "lattice") along with a few common instances.
Lattices are defined in two separate pieces: a _definition_ trait [`LatticeDe... | true |
7fefe1f3d1638d9692da923df858675cdcaa2334 | Rust | google/bongo | /src/parsers/tree.rs | UTF-8 | 17,350 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 Google LLC
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | true |
fdd6bfc202c6758449087ccc76a05bb14b357dad | Rust | jethrosun/lists | /src/third.rs | UTF-8 | 6,612 | 4 | 4 | [] | no_license | /// list1 = A -> B -> C -> D
/// list2 = tail(list1) = B -> C -> D
/// list3 = push(list2, X) = X -> B -> C -> D
///
/// list1 -> A ---v
/// list2 ------> B -> C -> D
/// list3 -> X ---^
///
/// Rust doesn't have anything like the garbage collectors these languages have. They have tracing
/// GC, which will dig through... | true |
0cd4ba4dd7a7ae30cfa93ec2d665afe1aa156971 | Rust | PsichiX/kaiju-toolset | /kaiju-vm-core/src/processor.rs | UTF-8 | 406 | 2.546875 | 3 | [
"MIT"
] | permissive | use crate::vm::Vm;
use core::error::*;
#[derive(Debug, Copy, Clone)]
pub enum OpAction {
None,
GoTo(usize),
Return,
}
pub trait Processor {
fn process_op(
_op: &String,
_params: &[usize],
_targets: &[usize],
_vm: &mut Vm,
) -> SimpleResult<OpAction> {
unimpl... | true |
975e3e86a474df525883ae444f6ff39f9dea11b3 | Rust | mrkgnao/sqlx | /sqlx-core/src/postgres/protocol/command_complete.rs | UTF-8 | 1,772 | 3.203125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use crate::io::Buf;
use crate::postgres::protocol::Decode;
#[derive(Debug)]
pub struct CommandComplete {
pub affected_rows: u64,
}
impl Decode for CommandComplete {
fn decode(mut buf: &[u8]) -> crate::Result<Self> {
// Attempt to parse the last word in the command tag as an integer
// If it ca... | true |
21da1b35432c9e58937f490e5a3efc9dda57c25b | Rust | varu3dbox/rust-sandbox | /algorithm_and_data_structure/chap02/src/bin/code_2_1.rs | UTF-8 | 230 | 2.796875 | 3 | [] | no_license | fn main() {
let mut N = String::new();
std::io::stdin().read_line(&mut N).ok();
let max_loop_count = N.trim().parse().ok().unwrap();
let mut count = 0;
while count < max_loop_count {
count += 1
}
} | true |
1333df526ee03c0bcb4863d5596f010e1a04f355 | Rust | adonm/rustercise | /src/main.rs | UTF-8 | 1,610 | 3.21875 | 3 | [
"Apache-2.0"
] | permissive | extern crate nanomsg;
use nanomsg::{Socket, Protocol, Error};
use std::io::{Read, Write};
use std::env;
use std::process;
static socket_address: &'static str = "tcp://127.0.0.1:8080";
/// Creating a new `Pull` socket type. Pull sockets can only receive messages
/// from a `Push` socket type.
fn create_socket() -> Res... | true |
ed5cb5511fd46d52e9127459197c98391c9cb865 | Rust | PhilipeLouchtch/rust-cardgame | /src/gamelogic/carddeck.rs | UTF-8 | 770 | 3.28125 | 3 | [] | no_license | use gamelogic::card;
use gamelogic::card::Card;
use gamelogic::vecshuffle::Shufflable;
#[derive(Debug)]
pub struct CardDeck {
cards: Vec<Card>,
}
impl CardDeck {
pub fn new() -> CardDeck {
let mut vec_cards = Vec::with_capacity(52);
for suit in card::Suit::iter_variants() {
for r... | true |
3e97fe24f3b9fe87fd25ee500c1fbf7e0efc2439 | Rust | msiemens/mlisp-rs | /src/parser/util.rs | UTF-8 | 463 | 3.484375 | 3 | [
"MIT"
] | permissive | //! Miscellaneous utilities
use std::borrow::ToOwned;
use std::rc::Rc;
// --- Shared string ------------------------------------------------------------
/// A string wrapped in a Rc
pub type SharedString = Rc<String>;
/// Create a shared string from a `&str`
pub fn rcstr<'a>(s: &'a str) -> SharedString {... | true |
ae13c62b253c7a192e22d33d33945b19681c2c68 | Rust | jozanza/re-winit | /vendor/owned_ttf_parser/src/owned.rs | UTF-8 | 2,636 | 3.25 | 3 | [
"ISC",
"Apache-2.0"
] | permissive | #[cfg(not(feature = "std"))]
use alloc::{boxed::Box, vec::Vec};
use core::{fmt, marker::PhantomPinned, pin::Pin, slice};
/// An owned version of [`Font`](struct.Font.html).
pub struct OwnedFont(Pin<Box<SelfRefVecFont>>);
impl OwnedFont {
/// Creates an `OwnedFont` from owned data.
///
/// You can set inde... | true |
afdc4882caeb6c34877ea4f442836f290460e82e | Rust | HiruNya/dawn-wait | /src/lib.rs | UTF-8 | 3,662 | 3.265625 | 3 | [
"MIT"
] | permissive | #![warn(missing_docs)]
#![doc(html_root_url = "https://hiru.dev/docs/dawn-wait/")]
//! This crate aims to provide an easy way to wait for new messages in a Discord channel.
//! This is meant to be used alongside the crates from the [dawn ecosystem].
//!
//! The equivalent of this in other languages/frameworks would be
... | true |
b2ba9444ee536e4bd7967eb95ac938a05c1dc7b0 | Rust | zfdyq0/pelite | /src/pe64/base_relocs.rs | UTF-8 | 6,780 | 3.0625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /*!
Base Relocations Directory.
The base relocations directory describes a list of addresses to pointer values within its module which need to be patched when the module is located at a different address than its preferred load address.
When the module contains pointers to itself these pointers need to be fixed when t... | true |
db7c565ec01e85955f3d611a544f863ff3fc681a | Rust | fenhl/aoc2019 | /src/day03.rs | UTF-8 | 4,241 | 3.234375 | 3 | [
"MIT"
] | permissive | use {
std::{
collections::HashMap,
error::Error,
fmt,
iter::FromIterator,
num::ParseIntError,
str::FromStr
},
derive_more::From,
itertools::Itertools as _
};
type Point = (i32, i32);
type Wire = HashMap<Point, u32>;
#[derive(Clone, Copy)]
enum Direction ... | true |
b364b924c3fcfc155e12f0b3e6cfb65707a83cb2 | Rust | emergent/ProjectEuler | /Rust/src/bin/027.rs | UTF-8 | 690 | 3.25 | 3 | [
"Unlicense"
] | permissive | /// Problem 27 - Project Euler
/// http://projecteuler.net/index.php?section=problems&id=27
use project_euler::prime::is_prime;
fn count_primes(a: i64, b: i64) -> i64 {
let mut n = 0;
let mut y = b;
while y > 0 && is_prime(y as u64) {
n += 1;
y = n * n + a * n + b;
}
n
}
fn main() ... | true |
0046749acb25a3dfb676fcacbe747e620c64646b | Rust | sergey-melnychuk/gossip-peer | /src/agent.rs | UTF-8 | 8,644 | 2.671875 | 3 | [
"MIT"
] | permissive | use std::fmt::{Debug, Error, Formatter};
use std::net::{IpAddr, SocketAddr};
use std::time::{SystemTime, UNIX_EPOCH};
use bytes::{Buf, BufMut, Bytes, BytesMut};
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct Info {
addr: Addr,
beat: u64,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct Reco... | true |
44bc1c679574fdf89cac98e950d171af3aedbe51 | Rust | joao-salomao/tic-tac-toe-game | /src/core/error.rs | UTF-8 | 450 | 3.3125 | 3 | [
"MIT"
] | permissive | #[derive(Debug)]
pub enum Error {
PositionInvalid,
PositionAlreadyMarked,
GameFinished,
GameOver,
}
impl Error {
pub fn message(&self) -> &str {
match self {
Self::GameOver => "Game over",
Self::GameFinished => "Game finished",
Self::PositionInvalid => "P... | true |
90ba317d8b0ca90febb36b067a73d2077ce0a5be | Rust | CyberFlameGO/abi_stable_crates | /abi_stable/src/abi_stability/extra_checks.rs | UTF-8 | 25,155 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | /*!
Contains items for adding checks to individual types.
# Implementing and using ExtraChecks
To add extra checks to a type follow these steps:
- Create some type and implement ExtraChecks for it,
- Apply the `#[sabi(extra_checks="const expression that implements ExtraChecks")]`
attribute to a type that uses `... | true |
a708f3084c93c229b938561f76de26b52443fcc0 | Rust | superoles/rescue_block_cipher | /src/cipher_tools/mds.rs | UTF-8 | 6,220 | 3.078125 | 3 | [] | no_license | use franklin_crypto::plonk::circuit::allocated_num::Num;
use franklin_crypto::bellman::pairing::Engine;
use franklin_crypto::bellman::plonk::better_better_cs::cs::ConstraintSystem;
use rand::Rng;
pub struct MdsMatrix<E: Engine, const SIZE: usize> {
data: [[Num<E>; SIZE]; SIZE]
}
impl<E: Engine, const SIZE: usize> Md... | true |
f6cccfc84fba09c41f050e26ce2d68522ceed6dd | Rust | yukihir0/rs_monkey | /src/ast.rs | UTF-8 | 2,099 | 3.421875 | 3 | [] | no_license | use std::fmt;
pub type Program = Vec<Statement>;
#[derive(PartialEq, Clone, Debug)]
pub enum Statement {
Let(Identifier, Expression),
Return(Expression),
Expression(Expression),
}
pub type BlockStatement = Vec<Statement>;
#[derive(PartialEq, Clone, Debug)]
pub struct Identifier(pub String);
#[derive(Pa... | true |
2d00d3f1f9608e9ac358b48fa91d5065323168a7 | Rust | TheChurro/Manifold-Tracer | /src/rendering/camera.rs | UTF-8 | 2,626 | 3.375 | 3 | [
"MIT"
] | permissive | use crate::math::quaternion::Quaternion;
use crate::math::ray::Ray;
use crate::math::vectors::Vec3;
use rand::distributions::Uniform;
use rand::{thread_rng, Rng};
pub struct Camera {
pub location: Vec3,
pub extents: Vec3,
pub horizontal: Vec3,
pub vertical: Vec3,
pub forward: Vec3,
pub lens_ra... | true |
d6365b52a6124636859b65bd34968e2b983f43fe | Rust | runarberg/math-text-transform | /src/variants/italic.rs | UTF-8 | 3,624 | 3.734375 | 4 | [
"MIT"
] | permissive | /// Transform a character to it's mathematical italic equivalent.
pub fn math_italic(c: char) -> Option<char> {
match c {
// Latin capital letters.
'A' => Some('𝐴'),
'B' => Some('𝐵'),
'C' => Some('𝐶'),
'D' => Some('𝐷'),
'E' => Some('𝐸'),
'F' => Some('𝐹')... | true |
6f72ee8ea79e8f1bd7426c6bfbe0051d7839be82 | Rust | faustfu/hello_rust | /src/mods/mo1.rs | UTF-8 | 2,477 | 3.6875 | 4 | [] | no_license | // Packages: A Cargo feature that lets you build, test, and share crates.
// A package is one or more crates that provide a set of functionality.
// A package contains a Cargo.toml file that describes how to build those crates.
// A package must contain zero or one library crates, and many... | true |
e72d7a2b967b181ff4d9c39a6877cfadf78036a9 | Rust | samsepy/sandbox | /rust/errors1/src/main.rs | UTF-8 | 194 | 2.859375 | 3 | [] | no_license | fn main() {
println!("hello");
panic_sample();
println!("world"); // panic_sampleが巻き戻され実行されない
}
fn panic_sample() {
let v = vec![1, 2, 3];
v[99];
}
| true |
dbca821f12f18f53cc908ef6ed5d9430a7487545 | Rust | rnleach/sounding-analysis | /src/lib.rs | UTF-8 | 5,805 | 3.078125 | 3 | [
"MIT"
] | permissive | // FIXME: Add some examples of using analysis functions.
/*!
[](https://github.com/rnleach/sounding-analysis/actions)
Functions and data types for analyzing soundings from radiosondes or models.
Library to represent an... | true |
d46b6025b5c5e956c2666a8036fb5b73eeeeb10e | Rust | jhspetersson/fselect | /src/output/html.rs | UTF-8 | 991 | 3.046875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-free-unknown"
] | permissive | use crate::output::ResultsFormatter;
pub struct HtmlFormatter;
impl ResultsFormatter for HtmlFormatter {
fn header(&mut self) -> Option<String> {
Some("<html><body><table>".to_owned())
}
fn row_started(&mut self) -> Option<String> {
Some("<tr>".to_owned())
}
fn format_element(&mu... | true |
8d98d3605cf18b220bad952709bead7872cf828b | Rust | marvelm/kuchiki | /examples/hyper.rs | UTF-8 | 899 | 2.8125 | 3 | [] | no_license | extern crate hyper;
extern crate kuchiki;
use hyper::Client;
use kuchiki::Html;
fn main() {
// Create a client.
let client = Client::new();
let url = "https://www.mozilla.org/en-US/";
println!("{} - {} ", "Calling site ", url);
// Get response
let mut response = client.get(url).send().unwrap... | true |
21f48037c089a0cb83c38bebcd339cd750ffe234 | Rust | stm32-rs/stm32-rs-nightlies | /stm32g0/src/stm32g081/tim2/cnt.rs | UTF-8 | 2,451 | 2.703125 | 3 | [] | no_license | #[doc = "Register `CNT` reader"]
pub type R = crate::R<CNT_SPEC>;
#[doc = "Register `CNT` writer"]
pub type W = crate::W<CNT_SPEC>;
#[doc = "Field `CNT_L` reader - Low counter value"]
pub type CNT_L_R = crate::FieldReader<u16>;
#[doc = "Field `CNT_L` writer - Low counter value"]
pub type CNT_L_W<'a, REG, const O: u8> =... | true |
49641e7efe46fb8568ef4d6ea09bd66fd75b77bb | Rust | Devolutions/devolutions-gateway | /crates/proxy-http/src/lib.rs | UTF-8 | 27,105 | 2.71875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Client and acceptor for HTTP(S) proxying / tunneling
//!
//! See [RFC 7231](https://datatracker.ietf.org/doc/html/rfc7231):
//! - [Section 4.3.6](https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.6)
//!
//! And [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230):
//! - [Section 2.3](https://datatracke... | true |
4d565ce6229314ab75b134099efd095a1c68d792 | Rust | pfirsich/adventofcode2019 | /6/rust/day6.rs | UTF-8 | 1,846 | 3.453125 | 3 | [] | no_license | use std::io::BufReader;
use std::io::BufRead;
use std::fs::File;
use std::collections::HashMap;
fn read_orbit_map(filename: &str) -> HashMap<String, String> {
let file = File::open(filename).unwrap();
let reader = BufReader::new(&file);
let mut map: HashMap<String, String> = HashMap::new();
for line in... | true |
4719bed93084e263320ad321a29607fc94a0d1c2 | Rust | lstange/mcgs | /rust_mt/src/main.rs | UTF-8 | 2,252 | 3.328125 | 3 | [
"MIT"
] | permissive | //
// Extreme spread of 2 to N shot groups, with impact coordinates pulled from bivariate
// standard normal distribution. Use dynamic programming: start with one shot group, add
// shots one by one. Keep track of group size so far, update it as new shots are being added.
// Update mean extreme spread for each group ... | true |
6f1ad616da0477eb3671545d6b47efd631dd1908 | Rust | badtuple/remits | /server/src/protocol.rs | UTF-8 | 889 | 2.796875 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
#[serde(tag = "kind")]
pub enum Body {
Ping(PingBody),
//LogShow(LogShowBody),
LogAdd(LogAddBody),
//LogDelete(LogDeleteBody),
//LogList(LogListBody),
MessageAdd(MessageAddBody),
//IteratorAdd(IteratorAddBody),
... | true |
bf6cac3bb79252164978f727764c5a4bff7b1fac | Rust | isabella232/odoh-client-rs | /src/dns_utils.rs | UTF-8 | 6,673 | 2.609375 | 3 | [
"BSD-2-Clause"
] | permissive | use anyhow::{anyhow, Result};
use futures::future::{self, Either};
use lazy_static::lazy_static;
use regex::Regex;
use std::str::FromStr;
use tokio::net::UdpSocket;
use trust_dns_client::rr::{DNSClass, Name, RData, RecordType};
use trust_dns_client::{
client::{AsyncClient, ClientHandle},
udp::UdpClientStream,
}... | true |
041452746fef74139518490ccfa21c8b42163048 | Rust | cx-emerge/terminal_commander | /src/ui/draw_window.rs | UTF-8 | 1,506 | 2.640625 | 3 | [
"MIT"
] | permissive | use std::{
fs, error,
};
use tui::{
Frame,
backend::Backend,
layout::{ Layout, Constraint, Direction, Rect, },
widgets::{ Block, Borders, Tabs, },
text::{ Spans, Span, },
style::{ Style, Color, },
};
use crate::components::{
traits::Component,
FileWindow,
};
pub struct FileWindowOptions<'a> {
pub is_activ... | true |
22a7ef9aa5e9592ac24c24b03de03d6c77217d75 | Rust | skyvoid123/rust-peg | /src/translate.rs | UTF-8 | 30,771 | 2.703125 | 3 | [
"MIT"
] | permissive | use std::borrow::ToOwned;
use std::collections::{ HashMap, HashSet };
use proc_macro2::{Ident, Span, TokenStream};
pub use self::Expr::*;
use codemap::{ Spanned, Span as CodemapSpan };
use PegCompiler;
fn raw(s: &str) -> TokenStream {
s.parse().expect("Lexical error")
}
pub(crate) struct Grammar {
pub imports: Vec<... | true |
0587d124bd6a7fe1f911526fb529c143eebf254d | Rust | redtankd/project-euler | /src/bin/00034.rs | UTF-8 | 609 | 2.953125 | 3 | [] | no_license | #[cfg(not(test))]
fn main() {
let t = project_euler::start_timer();
println!("\nsolution:");
println!("The answer is {:?}\n", s1());
project_euler::stop_timer(t);
}
fn s1() -> u32 {
(11u32..)
.filter(|n| {
*n == n
.to_string()
.chars()
... | true |
79232038a4c9432db4548ec1da88509f01a7a7fa | Rust | lprib/raymarcher | /src/render_3d/raymarcher.rs | UTF-8 | 6,143 | 2.75 | 3 | [] | no_license | use crate::vec3::Vec3;
use super::ray::cast_ray;
use super::scene_object::{Sphere, SceneObject};
use super::fractals::Julia;
use cgmath::Quaternion;
use rayon::prelude::*;
use std::path::Path;
use image::{DynamicImage, GenericImage, ImageFormat, Rgba};
use std::process::exit;
pub struct RayMarcher<O: SceneObject> {
... | true |
cded2c44a45d51e050cbf7bbea0eb1636afd11e0 | Rust | zaeleus/noodles | /noodles-fastq/src/record.rs | UTF-8 | 6,014 | 3.359375 | 3 | [
"MIT"
] | permissive | //! FASTQ record.
mod definition;
pub use self::definition::Definition;
use std::fmt;
/// A FASTQ record.
#[derive(Clone, Default, Debug, Eq, PartialEq)]
pub struct Record {
definition: Definition,
sequence: Vec<u8>,
quality_scores: Vec<u8>,
}
impl Record {
/// Creates a FASTQ record.
///
/... | true |
8186a68e1268a561a21c0bb43f85b0e215ad6924 | Rust | Actyx/rust-multibase | /src/error.rs | UTF-8 | 859 | 2.875 | 3 | [
"MIT"
] | permissive | use base_x;
use std::{error, fmt};
/// Error types
#[derive(PartialEq, Eq, Clone, Debug)]
pub enum Error {
UnknownBase,
InvalidBaseString,
}
pub type Result<T> = ::std::result::Result<T, Error>;
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(error... | true |
17fdccd96b8bc03147cc72e9b9809b84788725b1 | Rust | FrozenDroid/esp-idf-sys | /src/atomics_esp32c3.rs | UTF-8 | 6,106 | 2.578125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Support for ESP32-C3
// Temporary, until ESP-IDF V4.4 is released.
// V4.4 will have the very same functions currently implemented here as part of
// `components/newlib/stdatomic.c`
// Single core SoC: atomics can be implemented using portENTER_CRITICAL_NESTED
// and portEXIT_CRITICAL_NESTED, which disable and enab... | true |
78bc9b85649fc6c25c713d3d9baefb5621ac16a6 | Rust | yzhong52/AdventOfCode | /2019/src/y2019/day21.rs | UTF-8 | 3,601 | 3.453125 | 3 | [] | no_license | use crate::helpers::parser::read_numbers_by_comma;
use crate::int_code_computers::super_int_code_computer::SuperIntCodeComputer;
use crate::int_code_computers::super_int_code_computer::SuperIntCodeResult;
use crate::helpers::puzzle::Puzzle;
struct Springdroid {
computer: SuperIntCodeComputer,
}
impl Springdroid {... | true |
559a0993e0ebf2d95930e55b7daaa8058f325612 | Rust | dsbarnes/learning-rust | /chapter12/minigrep/src/lib.rs | UTF-8 | 3,348 | 3.953125 | 4 | [
"MIT"
] | permissive | //!# Minigrep
//!
//! A crate for searching through files
pub use grep::Config;
pub mod grep {
use std::fs::File;
use std::io::prelude::*;
use std::env::Args;
pub struct Config {
pub query: String,
pub filename: String,
pub case_sensitive: bool,
}
impl Config {
pub fn new(mut args: Args... | true |
17f40597a82813876e792582d1be90dfa1657c36 | Rust | rayleyva/rust_cmd_lib | /crates/cmd_lib_core/src/process.rs | UTF-8 | 12,941 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | use std::process::{Child, Command, ExitStatus, Stdio};
use std::io::{Error, ErrorKind};
use std::fs::{File, OpenOptions};
use std::os::unix::io::{FromRawFd, AsRawFd};
use std::collections::HashSet;
use crate::proc_env::Env;
use crate::proc_env::ENV_VARS;
use crate::{CmdResult, FunResult};
pub struct GroupCmds {
c... | true |
5ef61dadb0e9c8654b2535c4803a5cb1b7852f6c | Rust | fChristenson/nes-emulator | /src/lib/stack.rs | UTF-8 | 438 | 3.359375 | 3 | [] | no_license | use lib::memory::Memory;
pub struct Stack {
stack_pointer: u8,
}
impl Stack {
pub fn new() -> Stack {
Stack{stack_pointer: 0x01FF}
}
pub fn push(&mut self, memory: &mut Memory, value: u8) {
memory.write(self.stack_pointer, value);
self.stack_pointer -= 1
}
pub fn pop(&mut self, memor... | true |
cb1b0b55e3b299b32b88908eed786be648c0fabe | Rust | hasezoey/yt-downloader-rust | /crates/ytdlr/src/logger.rs | UTF-8 | 2,014 | 3.078125 | 3 | [
"MIT"
] | permissive | //! Module for all Logger related things
use colored::{
Color,
Colorize,
};
use flexi_logger::{
style,
DeferredNow,
Logger,
LoggerHandle,
Record,
};
/// Function for setting up the logger
/// This function is mainly to keep the code structured and sorted
#[inline]
pub fn setup_logger() -> LoggerHandle {
let h... | true |
0e0e6af81beec6d24e792b3e43932e4fec750027 | Rust | konbu310/rust-web-view-demo | /src/main.rs | UTF-8 | 1,315 | 2.78125 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use serde_json;
use web_view::*;
fn main() {
let html = format!(
r#"
<!doctype html>
<html>
<head>
{styles}
</head>
<body>
<div id="root"></div>
{scripts}
</body>
</html>
"#,
styles = inline_style(include_str!("../view/publi... | true |
a43095a6af10e2e31d8df1f95fa81f416e65d745 | Rust | Akavall/FileParsingTools | /src/set_func/bin/main.rs | UTF-8 | 1,584 | 3.53125 | 4 | [] | no_license | use std::env;
use std::io::BufReader;
use std::fs::File;
use std::io::prelude::*;
use std::collections::HashSet;
fn make_set_from_file (file_name: String) -> HashSet<String> {
let mut my_set: HashSet<String> = HashSet::new();
let f = File::open(file_name).unwrap();
let reader = BufReader::new(f);
for... | true |
54d7ded23ccdb6b66ba938720e7b99c2127f43f9 | Rust | ckampfe/manix | /src/blocking_client.rs | UTF-8 | 1,312 | 2.625 | 3 | [
"BSD-3-Clause"
] | permissive | use crate::async_client::AsyncClient;
use crate::torrent::Torrent;
use crate::Options;
use std::io::Read;
use std::path::PathBuf;
pub struct BlockingClient {
inner: AsyncClient,
rt: tokio::runtime::Runtime,
}
impl BlockingClient {
pub fn new(options: Options) -> Self {
let rt = tokio::runtime::Bui... | true |
9a92b4eb92f45896e67521ccbbfe40e49c69af4f | Rust | Arthaey/substudy | /src/merge.rs | UTF-8 | 2,656 | 3.4375 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | //! Tools for merge multiple subtitles into one.
use regex::Regex;
use srt::Subtitle;
static LINE_MAX: usize = 43;
/// Merge several subtitles into a single subtitle. Returns `None` if no
/// subtitles have been supplied, or if the resulting subtitle has no text.
pub fn merge_subtitles(subs: &[Subtitle]) -> Option... | true |
b4306c4aa49754413d62b598b097bd3322c8fcd7 | Rust | likebike/kerr | /tests/kerr.rs | UTF-8 | 625 | 2.703125 | 3 | [
"MIT"
] | permissive | use kerr::KErr;
#[test]
fn aaa_kerr() {
let mut e = KErr::new("ABC");
assert_eq!(format!("{}", e), "ABC");
assert_eq!(format!("{:?}", e), r#"KErr{ err:"ABC", chain:[] }"#);
e = e.pre("a");
assert_eq!(format!("{}", e), "a : ABC");
e = e.pre("b");
assert_eq!(format!("{}", e), "b : a : ABC");
... | true |
dc86794d343d2ad6f06968b85205b2c95146a5d6 | Rust | dfyz/osm-renderer | /src/perf_stats/real_impl.rs | UTF-8 | 6,236 | 2.828125 | 3 | [
"MIT"
] | permissive | use indexmap::IndexMap;
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::rc::Rc;
use std::time::Duration;
use std::time::Instant;
struct PerfStatsElement {
duration: Duration,
children: IndexMap<String, Rc<RefCell<PerfStatsElement>>>,
}
type PerfStatsElementRef = Rc<RefCell<PerfStatsElement>>;... | true |
c849c82d1714bda614d973c6104b6c8a9109ab60 | Rust | yuhonghong95721/anonify | /core/bc-connector/src/eventdb.rs | UTF-8 | 3,556 | 2.59375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::sync::Arc;
use anonify_common::{
kvs::{KVS, MemoryDB, DBTx}
};
use anonify_app_preluder::Ciphertext;
use anonify_runtime::{UpdatedState, traits::State};
use sgx_types::sgx_enclave_id_t;
use web3::types::Address;
use byteorder::{LittleEndian, ByteOrder};
use crate::error::Result;
pub trait BlockNumDB {
... | true |
2d76f493f33e2cbd120b05f364dd6386f588badc | Rust | jrduncans/timeturner | /src/converting.rs | UTF-8 | 11,987 | 3.328125 | 3 | [
"Apache-2.0"
] | permissive | use crate::DurationUnit;
use chrono::prelude::*;
use humantime::format_duration;
use std::convert::TryInto;
use std::time::Duration;
#[derive(PartialEq, Eq, Debug)]
pub enum ConversionFormat {
Rfc3339Utc,
Rfc3339Local,
EpochMillis,
DurationSince,
DurationSinceUnits(DurationUnit),
}
#[derive(Partia... | true |
6504792c6c4ed252c2bbd2690309847c34440b1c | Rust | unnsa/rust | /src/test/ui/unboxed-closures/unboxed-closures-infer-fn-once-move-from-projection.rs | UTF-8 | 902 | 2.84375 | 3 | [
"Apache-2.0",
"MIT",
"BSD-3-Clause",
"NCSA",
"LicenseRef-scancode-other-permissive",
"BSD-2-Clause"
] | permissive | // Copyright 2014 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 |
c22bf32dd0aa7e827edf8c0971cb725fa1664041 | Rust | ales-tsurko/image_uploader | /src/image/native_preview_maker.rs | UTF-8 | 2,596 | 2.765625 | 3 | [
"Unlicense"
] | permissive | use crate::{
ImageUploaderResult,
PREVIEW_SIZE,
};
use super::{
Image,
ImageType,
PreviewMaker,
};
use image::{
DynamicImage,
FilterType,
ImageFormat,
ImageOutputFormat,
load_from_memory_with_format,
};
use failure::Fail;
#[derive(Clone)]
pub struct NativePreviewMaker;
impl Pr... | true |
d50a05873a7717b945fa7d474abe7bf30d99a03a | Rust | teslaNova/np1th_irc | /examples/stream.rs | UTF-8 | 1,457 | 2.75 | 3 | [] | no_license | extern crate np1th_irc;
use std::thread::yield_now;
use np1th_irc::{command::client::Command::*, stream::{ClientStream, Port}};
fn main() -> Result<(), Box<std::error::Error>> {
println!("Trying to connect..");
if let Ok(stream) = ClientStream::connect("irc.freenode.org", Port::Secure(7000), None) {
... | true |
73ef7051a871a77bddcea893da173c7dd644c9ec | Rust | brettfazio/parallel-astar-rust | /src/benchmark.rs | UTF-8 | 3,053 | 2.796875 | 3 | [] | no_license | use criterion::{criterion_group, criterion_main, Criterion};
mod a_star;
use a_star::{
utils::structs::{HeurType, Flags},
hda,
dpa,
kpbfs,
utils::helpers::{parse_graph}
};
fn string_from_heur(heur: HeurType) -> String {
let heur_str = match heur {
HeurType::EuclideanDist => "euclidean",... | true |
b20b00ac6214cff55248cad727e5d678d0859004 | Rust | siriusdemon/rusticode | /leetcode/src/trie.rs | UTF-8 | 500 | 2.71875 | 3 | [] | no_license | // https://www.zhihu.com/question/318375802/answer/663596639
// Trie 树,也叫“字典树”。顾名思义,它是一个树形结构。它是一种专门处理字符串匹配的数据结构,用来解决在一组字符串集合中快速查找某个字符串的问题。
// 它的核心思想就是通过最大限度地减少无谓的字符串比较,使得查询高效率,即「用空间换时间」,再利用共同前缀来提高查询效率。
use std::rc::Rc;
use std::cell::RefCell;
| true |
bf04d69ef7d5fb38ff8a979e3ad828a9b306da32 | Rust | andymac-2/advent-of-code | /2019/src/day10.rs | UTF-8 | 4,030 | 3.234375 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::{HashMap, HashSet};
use std::convert::TryInto;
use std::io;
use std::io::Read;
use crate::parsers::*;
fn line_p(s: &[u8]) -> ParseResult<&[u8]> {
take_while1_p(|c| c == b'#' || c == b'.')(s)
}
fn arena_p(s: &[u8]) -> ParseResult<Arena> {
map(sep_by(line_p, byte(b'\n')), Arena)(s)
}
fn ... | true |
fc23af8adfdbdc405fee2759ab378b97e88c95f6 | Rust | rust-lang/cargo | /tests/testsuite/version.rs | UTF-8 | 1,299 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"GPL-2.0-only",
"Apache-2.0",
"MIT",
"GCC-exception-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Zlib",
"OpenSSL",
"curl",
"LGPL-2.1-only",
"BSD-2-Clause",
"LicenseRef-scancode-ssleay-windows",
"Unlicense"
] | permissive | //! Tests for displaying the cargo version.
use cargo_test_support::{cargo_process, project};
#[cargo_test]
fn simple() {
let p = project().build();
p.cargo("version")
.with_stdout(&format!("cargo {}\n", cargo::version()))
.run();
p.cargo("--version")
.with_stdout(&format!("cargo... | true |
a4ae343cb95ac117d0c8ba7b66e022cc03d0b416 | Rust | rome/tools | /crates/rome_formatter/src/printer/printer_options/mod.rs | UTF-8 | 2,868 | 3.515625 | 4 | [
"MIT"
] | permissive | use crate::{FormatOptions, IndentStyle, LineWidth};
/// Options that affect how the [crate::Printer] prints the format tokens
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PrinterOptions {
/// Width of a single tab character (does it equal 2, 4, ... spaces?)
pub tab_width: u8,
/// What's the max width... | true |
8d4062ade68860acd06b0976919d4559ae0dcc8e | Rust | house-of-vanity/polyfuse | /examples/examples/path_through.rs | UTF-8 | 17,035 | 2.640625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![allow(clippy::unnecessary_mut_passed)]
#![warn(clippy::unimplemented, clippy::todo)]
// This example is another version of `passthrough.rs` that uses the
// path strings instead of the file descriptors with `O_PATH` flag
// for referencing the underlying file entries.
// It has the advantage of being able to use st... | true |
194ae433b36e5ce3486a0eceeee580f33e175274 | Rust | vcombey/fallible_collections | /src/rc.rs | UTF-8 | 831 | 3.28125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Implement a Fallible Rc
use super::FallibleBox;
use crate::TryReserveError;
use alloc::boxed::Box;
use alloc::rc::Rc;
/// trait to implement Fallible Rc
pub trait FallibleRc<T> {
/// try creating a new Rc, returning a Result<Box<T>,
/// TryReserveError> if allocation failed
fn try_new(t: T) -> Result<Se... | true |
8ef4b439de1cb483b95b4d1f048040c856b36e77 | Rust | Freax13/sleigh | /src/spec/precedence/constraint.rs | UTF-8 | 3,465 | 2.875 | 3 | [] | no_license | use super::Fix;
use crate::{impl_for_binary_operation, impl_for_unary_operation, spec::constraint::*};
impl Fix<Constraint> for Constraint {
fn fix(&self) -> Constraint {
match self {
Constraint::Ellipsis(inner) => inner.fix(),
Constraint::And(inner) => inner.fix(),
Cons... | true |
11ad11a5061a39fbe9617960f2a739bcac8ec31d | Rust | nfjBill/rust-gmsm | /src/g2/p256.rs | UTF-8 | 40,833 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | use num::bigint::{BigUint, ToBigInt};
use num_bigint_dig::{BigUint as BigUnitDig, ModInverse};
use std::sync::{Once};
use std::{mem};
use num::{Num, Integer, ToPrimitive, FromPrimitive, BigInt};
use std::ops::{Shl, Shr, Add, Mul, Sub, BitAnd};
use std::cmp::Ordering;
use lazy_static::lazy_static;
use crate::g2::consts:... | true |
986dcdb1034813c56e3fa862e7e9c82898212750 | Rust | kkysen/mklink | /src/error.rs | UTF-8 | 2,796 | 3.3125 | 3 | [
"MIT"
] | permissive | use std::{io, fmt};
use std::path::Path;
use std::fmt::{Display, Formatter};
#[derive(Debug)]
pub struct Error<'a> {
pub message: Option<&'a str>,
pub paths: Vec<&'a Path>,
pub program: Option<&'a str>,
pub error: Option<io::Error>,
}
struct DisplayOption<'a, T : Display> {
name: &'a str,
opti... | true |
b000c40073174422ce644b8c88b5926b97afaa18 | Rust | argmin-rs/argmin | /argmin/examples/simulatedannealing.rs | UTF-8 | 5,335 | 2.8125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2018-2022 argmin 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 according... | true |
561bfe63c7556a98a388a2473f04b7a59b5e3cdc | Rust | patchispatch/MH2021 | /src/par/partition.rs | UTF-8 | 7,118 | 3.328125 | 3 | [] | no_license | use super::Problem;
use std::collections::{HashSet, BTreeMap};
use std::fmt;
use rand::Rng;
use na::DVector;
use rand_pcg::Pcg64;
// Custom types
pub type Point = DVector<f64>;
/// Struct to represent and manage a partition
/// - cluster_index: HashMap<usize, usize> Map to check the cluster containing an element
///... | true |
347a646e301274f71e83636cb19da6f9c0075d4b | Rust | loliomg/hitcat | /src/size.rs | UTF-8 | 187 | 2.75 | 3 | [] | no_license | pub struct Size {
pub width: f32,
pub height: f32,
}
impl Size {
pub fn square(x: f32) -> Self {
Self {
width: x,
height: x,
}
}
}
| true |
b3112c1e0e0874575359d54d8c0783038b3e73eb | Rust | fenhl/mediawiki-dump | /src/main.rs | UTF-8 | 4,559 | 2.578125 | 3 | [
"MIT"
] | permissive | extern crate xml5ever;
extern crate tendril;
use std::{env, iter};
use std::fs::{self, File};
use std::io::prelude::*;
use std::path::Path;
use tendril::{ByteTendril, ReadExt};
use xml5ever::rcdom::{NodeEnum, RcDom};
fn main() {
let mut args = env::args();
let db_path = args.next().expect("missing XML dump ... | true |
dc2e7a33e9b320cc053ba2d33603e82877cd66ad | Rust | duxet/serde-xml-rs | /src/error.rs | UTF-8 | 2,531 | 2.828125 | 3 | [
"MIT"
] | permissive | use xml::reader;
use std::fmt::{self, Display, Debug};
use std::error::Error as StdError;
use std::num;
use serde::de::Error as SerdeError;
pub enum Error {
ParseIntError(num::ParseIntError),
Syntax(reader::Error),
Custom(String),
}
pub type VResult<V> = Result<V, Error>;
macro_rules! expect {
($actu... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.